1.html
<!DOCTYPE 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>Document</title>
</head>
<body>
<div>1212</div>
<script type="module">
import {add as newadd} from './b.js'
let res = newadd(2,3)
console.log(res)
</script>
</body>
</html>
2.b.js
import cal from './calculatores.js'
console.log('sum: ', cal.add(1,2))
function add(a, b) {
return a + b + 2;
}
export { add };
3.calculatores.js
export default {
add: function(a, b) {
return a + b
}
}
非框架 js引用写法
最新推荐文章于 2022-04-18 11:07:10 发布