First check whether there is any error in the console; then check whether the written js complies with AMD/CMD specifications. Of course it is best to define define()
Quoting Ruan Yifeng’s tutorial: http://www.ruanyifeng.com/blo... require.js has several important APIs. define defines the module, the default file name is the name of the module. require Just write the name of the module in the array without the suffix (.js). Configure the reference path for module introduction, then define the module, and then introduce the module.
It is normal that the request cannot be received. Your page.js does not write the AMD loading header, and require.js does not recognize it at all.
If there is an AMD header, load it normally. If there is no AMD header, use require.config to configure the shim.
Add an AMD header to page.js or directly add a UMD header (that is, it can be loaded with AMD/CMD at the same time, and can be seen in many modules on github).
Please refer directly to Ruan Yifeng’s RequireJS and AMD specifications for the documentation.
1: What do you mean by not being able to request?
console.log(Page)
No output?Open the network tab in the developer tools and you should be able to see the request for page.js
2: It can be obtained and run, but the Page variable in the callback function is undefined because you did not define it in Page.js
3:
First check whether there is any error in the console; then check whether the written js complies with AMD/CMD specifications.
Of course it is best to define define()
Quoting Ruan Yifeng’s tutorial: http://www.ruanyifeng.com/blo...
require.js has several important APIs.
define defines the module, the default file name is the name of the module.
require Just write the name of the module in the array without the suffix (.js).
Configure the reference path for module introduction, then define the module, and then introduce the module.
It is normal that the request cannot be received. Your page.js does not write the AMD loading header, and require.js does not recognize it at all.
If there is an AMD header, load it normally. If there is no AMD header, use require.config to configure the shim.
Add an AMD header to page.js or directly add a UMD header (that is, it can be loaded with AMD/CMD at the same time, and can be seen in many modules on github).
Please refer directly to Ruan Yifeng’s RequireJS and AMD specifications for the documentation.