Can I use Require.js in development without using the data-main
attribute to load in my initial script? ie. <script data-main="scripts/main" src="scripts/require.js"></script>
I'm finding it difficult for me to work with this attribute in my development environment.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Yep, take a look at the documentation: http://requirejs.org/docs/api.html#config
You need to call require.config() and set baseUrl. Based on your example:
<script src="scripts/require.js"></script>
<script>
require.config({
baseUrl: "scripts"
});
require( [ /*...*/ ], function( /*...*/ ) {
/*...*/
});
</script>