seaJs模块化APPCAN

2026-02-17 10:29:08

1、如果要将appcan基础JS文件模块化,将JS代码加上define(function(require, exports, module){return function(e){(function(appcan){。。。。。})(e)}})

2、config.js配置别名和路径

seajs.config({    alias: {         'control': './../../js/appcan.control.js',        'main' : './main.js',        'uexLocation':'./../../plugin/uexLocation.js',     },               paths:{         "root" : "./../../../",         "module" : "./../module2/"     },          map : []});

3、html页面先添加JS文件

<script src="./js/appcan.js"></script>         <script src="public/js/sea.js"></script>

然后,将页面脚本也做一个模块化

seajs.use("./public/js/config")        define(function(require){            require("control")(appcan)        appcan.ready(function() {            var titHeight = $('#header').offset().height;            appcan.frame.open("content", "index_content.html", 0, titHeight);            window.onorientationchange = window.onresize = function() {                appcan.frame.resize("content", 0, titHeight);            }        });    });

注:主,子页面都要做此操作

相关推荐
  • 阅读量:194
  • 阅读量:176
  • 阅读量:172
  • 阅读量:36
  • 阅读量:66
  • 猜你喜欢