






























index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="module" src="./math.js"></script>
<script type="module" src="./util.js"></script>
</head>
<script type="module">
import {hello, getMsg} from './util.js'
window.changeDivContent = function() {
var divElement = document.getElementById('content')
console.log('js i am coming...')
divElement.innerHTML = getMsg()
}
</script>
<body>
<h1>Demo</h1>
<div id="content"></div>
<button onclick="changeDivContent()">显示内容</button>
</body>
<script>
</script>
</html>
math.js
export function sum(a, b){
return a+b
}
function hello(){
return 'hello math'
}
util.js
import {sum} from './math.js'
export function hello() {
return 'hello util'
}
export function getMsg() {
let sum_result = sum(1, 2)
console.log('sum_result:' + sum_result)
return sum_result
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。