-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
表示看不懂test里面的例子,看了好几天 #51
Comments
|
@hefangshi 对啊,没有导出何来的引入,能不能加个qq好友,刚入行有很多都不懂,希望可以请教一下 |
不用QQ了,可以调试一下看看,如果 |
@hefangshi 那个前辈的代码我是真心搞不懂 demo文件中的代码: 这个我是按照我的理解来写的,然后报了一个报错了:mod.js:141 Uncaught [ModJS] Cannot find module |
因为他没有使用require.resourceMap去设置 @hefangshi |
我知道我不明白的地方在什么地方了,例如说:我定义了sum.js文件,在sum.js文件中使用define(
//------------------------------------------------------------ |
mod.js 主要还是搭配 fis 一起用的,会自动注意依赖信息之类,如果你就单纯的用,使用成本可能有点高。 可以看下这个 demo https://github.com/fex-team/fis3-demo/tree/master/use-mod.js |
花了些时间去看mod.js的源码,对照我昨天看的http://annn.me/how-to-realize-cmd-loader/ 这个案例,核心思想就是动态生成script标签,然后加载相对应的模块代码吧? |
把fis和mod结合用啦。。灰常简单的。。用fis自动给js包起来就好了。 |
刚入行没多久,看到一个前辈使用的modjs这个工具,然后想学习一下,发现他使用的方式和网上使用的方式有很大的不同,然后现在我两种方法都没有出现效果
它使用的方式是这样的:
define('modules/jquery/jquery-2.2.4.min', function(require, exports, module) {
然后这里面就跟着框架或插件的源码,也没有导出啥的,require, exports, module这三个参数也没有用到
});
页面引用:
<script src="__TMPL__Public/movies/js/mod.js"></script> <script type="text/javascript" src="__TMPL__Public/movies/modules/jquery/tool.js"></script> <script type="text/javascript" src="__TMPL__Public/movies/modules/jquery/jquery-2.2.4.min.js"></script> <script type="text/javascript" src="__TMPL__Public/movies/modules/jquery/jquery.tap.js"></script> <script type="text/javascript" src="__TMPL__Public/movies/modules/jquery/pinchzoom.js"></script> <script type="text/javascript" src="__TMPL__Public/movies/modules/jquery/ajaxForm.js"></script> <script> //模块化 window.$ = window.jQuery = require('modules/jquery/jquery-2.2.4.min'); require('modules/jquery/jquery.tap'); require('modules/jquery/pinchzoom'); require('modules/jquery/tool'); require('modules/jquery/ajaxForm'); </script>就是这样了,看着网上提供的例子,然后又看着他写的,就一脸的懵逼了
The text was updated successfully, but these errors were encountered: