Vue篇——前端模块化雏形
作者:互联网
// aaa.js
var moduleA = (function() {
var obj = {}
var name = '小明'
var age = 12
function sum(num1, num2) {
return num1 + num2
}
var flag = true
if (flag) {
console.log(sum(10, 20));
}
obj.flag = flag;
obj.sum = sum;
return obj
})()
//bbb.js
;(function(){
var name ='小红'
var flag = false
console.log(name);
})()
// mmm.js
(function(){
if(moduleA.flag){
console.log('小明');
}
console.log(moduleA.sum(40,50))
})()
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
<script src="aaa.js"></script>
<script src="bbb.js"></script>
<script src="mmm.js"></script>
<script src="main.js"></script>
</html>
标签:function,Vue,console,log,模块化,sum,雏形,flag,var 来源: https://blog.csdn.net/weixin_47016497/article/details/114260323