JS模块化
2021-05-02 23:30
标签:content back func ack ons name view har com 输出:vicin JS模块化 标签:content back func ack ons name view har com 原文地址:https://www.cnblogs.com/vichin/p/12123855.htmlDOCTYPE html>
html lang="en">
head>
meta charset="UTF-8">
meta name="viewport" content="width=device-width, initial-scale=1.0">
meta http-equiv="X-UA-Compatible" content="ie=edge">
title>Documenttitle>
head>
body>
p>2p>
script src="myScript.js">script>
script>
person.printName();
script>
body>
html>
var person = (function () {
var name = ‘vicin‘;
var age = 28;
var printName = function () {
console.log(name)
}
var printAge = function () {
console.log(age);
}
return {
printName: printName,
printAge: printAge
}
})();