[英]What's the meaning of .js file of the form “define([…], function(…) {…});”
I have .js files of the following form: 我有以下形式的.js文件:
define([
'jquery',
'backbone'
], function($, Backbone) {
// function stuff here
}
What's the purpose of writing the file that way? 以这种方式编写文件的目的是什么? Is it some convention to define it like that?
这样定义它是一种约定吗?
They're using the CommonJS AMD-style definitions to register modules. 他们使用CommonJS AMD风格的定义来注册模块。
Info: http://www.sitepen.com/blog/2010/11/04/requirejsamd-module-forms/ 信息: http : //www.sitepen.com/blog/2010/11/04/requirejsamd-module-forms/
The first argument is the module dependencies, and the second is the module itself. 第一个参数是模块依赖项,第二个参数是模块本身。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.