gpt4 book ai didi

javascript - require 函数是 AMD 规范的一部分吗?

转载 作者:行者123 更新时间:2023-11-28 09:20:53 24 4
gpt4 key购买 nike

我最近一直在使用 AMD 模块和 RequireJS,我试图弄清楚 AMD 规范到底是什么。到目前为止,我唯一能找到的是 amdjs GitHub 页面 https://github.com/amdjs/amdjs-api/wiki/AMD

此页面仅显示作为官方规范一部分的define( id,dependency,factory)函数。 Require 还有另一个名为 require(dependency,callback) 的函数,我不确定它是否是官方规范的一部分,或者它是否只是 RequireJS 库提供的一个方便函数。

最佳答案

在您链接的页面中,全局变量标题下:

This specification reserves the global variable "define" for use in implementing this specification, the package metadata asynchronous definition API and is reserved for other future CommonJS APIs. Module loaders SHOULD not add additional methods or properties to this function.

This specification reserves the global variable "require" for use by module loaders. Module loaders are free to use this global variable as they see fit. They may use the variable and add any properties or functions to it as desired for module loader specific functionality. They can also choose not to use "require" as well.

Curl是一个不使用 require 的 AMD 加载器示例。

此外there is a page that details the require API对于支持它的加载器。

关于javascript - require 函数是 AMD 规范的一部分吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14993675/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com