Vue学习笔记(一)JS导入导出
js文件-导出、批量导出、默认导出
showMessage.js
export function simpleMessage(msg){
console.log(msg);
}
export function complexMessage(msg){
console.log(new Date()+": "+msg);
}
// 批量导出
// export {simpleMessage,complexMessage}
// 默认导出
// export default {simpleMessage,complexMessage}
html文件-导入js
message.html
<body>
<div id="app">
<button id="btn">点我展示信息</button>
</div>
<script type="module">
import {complexMessage} from './showMessage.js';
// import mm from './showMessage.js';
document.getElementById("btn").onclick=function(){
complexMessage("我被点击了......");
// mm.complexMessage("默认导出点击事件哦......");
}
</script>
</body>