當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Fabric.js resolveNamespace()用法及代碼示例

resolveNamespace()方法用於返回指定名稱空間的對象。

用法:

resolveNamespace(namespace)

參數:此方法接受如上所述和以下描述的參數:

  • namespace:此參數保存指定的名稱空間字符串,例如“ fabric.Image.filter”,‘fabric’等。

返回值:此方法返回指定名稱空間的對象。

範例1:



Javascript

<!DOCTYPE html>
<html>
 
<head>
  <!-- Adding the FabricJS library -->
  <script src=
"https://cdnjs.cloudflare.com/ajax/libs/fabric.js/3.6.2/fabric.min.js">
  </script>
</head>
 
<body>
<script type="text/javascript">
 
  /* Calling resolveNamespace() function over
    the specified namespace */
  console.log(fabric.util.resolveNamespace("fabric.Observable"));
  console.log(fabric.util.resolveNamespace("fabric.util"));
</script>
 
</body>
 
</html>

輸出:

{}
{"array":{},"object":{},"string":{},"ease":{}}

範例2:

Javascript

<!DOCTYPE html>
<html>
 
<head>
  <!-- Adding the FabricJS library -->
  <script src=
"https://cdnjs.cloudflare.com/ajax/libs/fabric.js/3.6.2/fabric.min.js">
  </script>
</head>
 
<body>
<script type="text/javascript">
 
   // Specifying some namespace
   var namespace1 = "fabric.CommonMethods";
   var namespace2 = "fabric.Collection";
 
  /* Calling resolveNamespace() function over
     the above specified namespace*/
  console.log(fabric.util.resolveNamespace(namespace1));
  console.log(fabric.util.resolveNamespace(namespace2));
</script>
 
</body>
 
</html>

輸出:

{}
{"_objects":[]}

相關用法


注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 Fabric.js resolveNamespace() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。