化拓教育网
您的当前位置:首页js文件包含的几种方式介绍_javascript技巧

js文件包含的几种方式介绍_javascript技巧

来源:化拓教育网


1. 页面中直接引用

代码如下:
<\/script>
<\/script>

2.动态写入页面

代码如下:
document.write('<\/script>')
document.write('<\/script>')

3.模拟包含函数

代码如下:
function include(path){
var a=document.createElement("script");
a.type = "text/javascript";
a.src=path;
var head=document.getElementsByTagName("head")[0];
head.appendChild(a);
}

include("a.js")

include("b.js")

4.js模块化编程

require.js的方法

显示全文