require js 将config和入口函数分开写
原文地址
https://github.com/jrburke/requirejs/issues/354
Area there any plans to standardize/recommend a particular approach? If there is, I would suggest the following:
// homepage.html <script data-id="requirejs" data-logic="home" data-main="js/config" src="js/lib/require.js"></script>
In, config.js
require.config({
baseUrl: 'js'
});
// Load app logic as specified in `data-logic` attribute
require([document.querySelector('script[data-id="requirejs"]').getAttribute("data-logic")]);