I am a complete novice about modular programming, I hope you can give me some advice
In my index.html, index.js needs to call zepto.js in the component component, but it cannot be called normally, and there is no alarm. mistake;
index.js source code is as follows:
After publishing to the test machine using fis3, index.js becomes Now:
In this code define('static/index/index', function(...){}, this function wraps all the source code content, so it cannot run normally. If you remove the outer function of this define, it can It works normally. But the question is why it is automatically generated, and how should I write index.js so that there will be no problems;
滿天的星座2017-05-16 13:47:38
zepto’s default library does not include the AMD module, which means it cannot be loaded with AMD. If you use requirejs to load it, you need to write it into the shim. Here is a config I wrote before:
require.config({
paths: {
'zepto': 'zepto.min',
'weixin': '//res.wx.qq.com/open/js/jweixin-1.2.0',
'vconsole': 'vconsole.min'
},
shim: {
'zepto': {
exports: '$'
}
}
});
But I haven’t solved why it doesn’t work if I build the zepto module with the AMD module (maybe the compiled library is not compliant or there is a problem with zepto’s AMD itself?)... It can be said that this is a comparison Lazy solution.
In addition, I have never used Fis, but when using requirejs, I usually use a script tag in HTML to solve the problem, such as:
<script data-main='js/main.js' src="js/require.min.js"></script>
Then just write the requirements into main.js.
Add a zepto build address.