在html中引入外部js文件,并调用带参函数的方法
在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 测试结果

相关推荐
Zhongmeishijue 2020-09-10
runner 2020-09-01
梦的天空 2020-08-25
IdeaElements 2020-08-19
luvhl 2020-08-17
移动开发与培训 2020-08-16
ReunionIsland 2020-08-16
lyqdanang 2020-08-16
NARUTOLUOLUO 2020-08-03
MyNameIsXiaoLai 2020-07-08
星辰的笔记 2020-07-04
csstpeixun 2020-06-28
letheashura 2020-06-26
liaoxuewu 2020-06-26
OldBowl 2020-06-26
北京老苏 2020-06-25
Luffyying 2020-06-25