Loading

Sea.js入门

Sea.js入门

学习了:

https://www.cnblogs.com/doseoer/p/4007752.html

https://blog.csdn.net/love_is_all_in_life/article/details/50354367

https://www.jianshu.com/p/ebdf2233e3fe  这个参考一下

#930问题:https://github.com/seajs/seajs/issues/930

==================================================

sea.js require路径的问题,

文件结构:

test01.html
sea-modules/sea-debug.js
static/test01.js
static/changeText.js

test01.html:

    <script src="sea-modules/sea-debug.js" ></script>
    <script>
        seajs.config({
            alias:{
                'changeText':'./changeText.js'
            }
        });
        seajs.use('./static/test01.js')
    </script>

test01.js:

define(function (require, exports, module) {
    // var changeText = require('./changeText.js');
    var changeText = require('changeText');
    var title = document.getElementById('title');
    // title.innerHTML = 'aaa';
    title.innerHTML = changeText.init();
});

使用require命令的时候,路径是相对于引用文件test01.js的,而且必须以.或者..开头,如果不是以.或者..开头,就取sea-bug.js目录了;

使用use命令的时候,路径是相对于html文件的;

文件结构是:

test01.html
sea-modules/sea-debug.js
static/hello/test01.js
static/hello/changeText.js

也是一样的,也是使用同样的require语句;

文件结构是:

test01.html
sea-modules/seajs/seajs/2.2.0/sea-debug.js
static/hello/test01.js
static/hello/changeText.js

也是一样的,也是使用同样的require语句;

学习了:https://www.cnblogs.com/ada-zheng/p/3284660.html

其中的data-config是html5引入的属性,被seajs使用了,在源码中可以看到;

 

posted @ 2018-05-10 20:55  stono  阅读(169)  评论(0编辑  收藏  举报