tree一下
. ├── aaa.html └── js ├── jquery.min.js ├── main.js ├── myjs.js └── require.js
aaa.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script src="js/require.js" data-main="js/main"></script> </body> </html>
main.js
requirejs.config({ urlArgs: Date.now(), //baseUrl: ‘js‘, paths: { jquery: ‘./jquery.min‘, myjs: ‘./myjs‘ } }); require([‘jquery‘,‘myjs‘], function(m1, m2) { alert(m2.getHello()); });
myjs.js
define(function () { return { getHello: function () { return ‘Hello World‘; } }; });
时间: 2024-11-05 14:39:27