时间:2021-04-27 09:10:35 | 栏目:JavaScript代码 | 点击:次
在html中引入外部js文件,并调用js文件中的带参函数
1 项目结构

2 编写a.js、test.html
//a.js
function abc(str){
alert(str);
}
//test.html
<html>
<head>
<script type="text/javascript" src="a.js"></script>
<script type="text/javascript">
window.onload = function(){
var fun = abc; //引用abc函数
fun(123);
};
</script>
</head>
<body>
</body>
</html>
3 测试结果
