From a065e04d529da1d847b5062a12c46d916408bf32 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 21:46:22 -0500 Subject: update based on https://github.com/mdn/yari/issues/2028 --- files/zh-cn/components.utils.import/index.html | 82 -------------------------- 1 file changed, 82 deletions(-) delete mode 100644 files/zh-cn/components.utils.import/index.html (limited to 'files/zh-cn/components.utils.import/index.html') diff --git a/files/zh-cn/components.utils.import/index.html b/files/zh-cn/components.utils.import/index.html deleted file mode 100644 index 2ae0425882..0000000000 --- a/files/zh-cn/components.utils.import/index.html +++ /dev/null @@ -1,82 +0,0 @@ ---- -title: Components.utils.import -slug: Components.utils.import -translation_of: Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.import ---- -

- -

这个方法在 Firefox 3 中被引入,它使得在不同的作用域之间分享代码变得更加容易。例如:你可以直接导入 XPCOMUtils.jsm 而不必复制/粘贴冗长的XPCOM组件。

- -

查看 Using JavaScript code modules 了解更多细节。

- -
-

Note:  Gecko 2.0  之前, JavaScript code modules 仅可以使用  file:resource: URLs. Gecko 2.0 引入了对 chrome: URLs, even those inside JAR archives 的支持。

-
- -

Syntax(语法)

- -
Components.utils.import(url [, scope]);
-
-// Or, if you use a tool such as jslint which reports compiler errors for the above,
-
-Components.utils["import"](url [, scope]);
- -

Parameters(参数)

- -
-
url
-
一个将被导入的script的URL,这个URL必须是在磁盘上的一个文件,可能在JAR之中。
-
scope
-
一个可选的导入对象,如果省略则使用全局对象。当读取文件发生错误(如语法错误等)时会抛出异常。
-
- -

Example(例子)

- -
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-
- -

Difference from mozIJSSubScriptLoader(与mozIJSSubScriptLoader的区别)

- -

The differences from mozIJSSubScriptLoader:

- - - -

Additional Resources(其他资源)

- - - -

-- cgit v1.2.3-54-g00ecf