异步加载js,css

方法

方法

css

css
(
  • css
)

异步加载css资源

参数:

名称类型标识描述
css Array 必选

需要异步加载的css资源的路径的集合

示例:

文件导入路径:
M3App端
 <script  src="http://cmp/v1.0.0/js/cordova/__CMPSHELL_PLATFORM__/cordova.js"></script>
 <script  src="http://cmp/v1.0.0/js/cordova/cordova-plugins.js"></script>
 <script  src="http://cmp/v/js/cmp.js"></script>
 <script  src="http://cmp/v/js/cmp-asyncLoad"></script>
 ===========================================================================================
 微协同端:
 <script  src="/seeyon/m3/cmp/js/cmp.js"></script>
 <script  src="http://cmp/v/js/cmp-asyncLoad"></script>
 =========================================================================================
<script>
    cmp.asyncLoad.css(["../../sources/js/cmp-listView.css","http://xxxx.css"]);
</script>

js

js
(
  • jss
  • callback
)

异步加载js资源

参数:

名称类型标识描述
jss Array 必选

需要异步加载的js资源的路径的集合,数组元素接受格式可以直接是路径字符串或对象形式包含id和url字符串

callback Function 必选

所有js加载完成的回调函数

示例:

文件导入路径:
M3App端
 <script  src="http://cmp/v1.0.0/js/cordova/__CMPSHELL_PLATFORM__/cordova.js"></script>
 <script  src="http://cmp/v1.0.0/js/cordova/cordova-plugins.js"></script>
 <script  src="http://cmp/v/js/cmp.js"></script>
 <script  src="http://cmp/v/js/cmp-asyncLoad"></script>
 ===========================================================================================
 微协同端:
 <script  src="/seeyon/m3/cmp/js/cmp.js"></script>
 <script  src="http://cmp/v/js/cmp-asyncLoad"></script>
 =========================================================================================
<script>
    //=====M3端================
    cmp.asyncLoad.js(["http://cmp/v/js/cmp-listView.js","http://xxxx.js",{id:"oneJS",url:"http://xxx/oneJS.js"}],
    function(){
         dosomething
    });
    //=====微协同端=============
    cmp.asyncLoad.js(["/seeyon/m3/cmp/js/cmp-listView.js","http://xxxx.js",{id:"oneJS",url:"http://xxx/oneJS.js"}],
    function(){
         dosomething
    });
</script>
Top