工作中用seajs一段时间了,小小地总结一下。

使用seajs五部曲:

    1.布置你项目的目录结构

    2.设置seajs的config项,我一般是单独一个js文件--> seajs-config.js,  主要是重置一下base路径,一般比较少用paths,而用alias比较多,因为项目上线前直接把alias这些配置给grunt直接构建提取模块id  

 1 /**
 2  * 配置项目
 3  *
 4  */
 5 seajs.config({
 6     "base": "/js",
 7     "paths": {
 8         "seajs": "sea-modules/seajs"
 9     },
10     "alias": {
11         "jquery": "sea-modules/library/jquery/1.11.1/jquery.js",
12         "bindonce": "sea-modules/library/angular/1.2.20/bindonce.js",
13         "handlebars": "sea-modules/library/handlebars/1.3.0/handlebars.js",
14         "mustache": "sea-modules/library/mustache/0.8.1/mustache.js",
15         "angular": "sea-modules/library/angular/1.3.0-beta.15/angular.min.js",
16         "iscroll5": "sea-modules/library/iscroll/iscroll.js",
17         "cart": "sea-modules/custom/cart/1.1.0/cart.js",
18         "favorite": "sea-modules/custom/favorite/0.1.0/favorite.js",
19         "cookies": "sea-modules/custom/cookies/0.1.0/cookies.js",
20         "globalloading": "",
21         "tipslayer": "sea-modules/custom/tipslayer/0.1.0/tipslayer.js",
22         "verify": "sea-modules/custom/verify/0.1.0/verify.js",
23         "slider": "sea-modules/custom/slider/0.2.0/slider.js",
24         "tips": "sea-modules/custom/tips/1.2.0/tips.js",
25         "share": "sea-modules/custom/share/0.2.0/share.js",
26         "lazyload": "sea-modules/custom/lazyload/0.1.0/lazyload.js",
27         "emoji": "sea-modules/custom/emotion/zepto_emoji.js",
28         "iscroll": "sea-modules/custom/iscroll/4.2.5/iscroll.js",
29         "dialog": "sea-modules/custom/dialog/1.1.1/dialog.js",
30         "pageloader": "sea-modules/custom/pageloader/0.1.0/pageloader.js",
31         "loading": "sea-modules/custom/loading/0.1.0/loading.js",
32         "report": "sea-modules/custom/report/report.js",
33         "imgbrowse": "sea-modules/custom/imgbrowse/0.1.0/imgbrowse.js",
34     },
35     "map": [
36         // [".js", ".js?v2"]
37     ],
38     "debug": 2
39 });
40     
View Code

相关文章:

  • 2022-12-23
  • 2022-02-12
  • 2022-01-26
  • 2021-07-13
  • 2022-01-12
  • 2022-12-23
  • 2021-11-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-03
  • 2021-10-28
  • 2021-12-12
  • 2021-05-22
  • 2022-12-23
相关资源
相似解决方案