**html 原生 js 模块 导入 导出**
vscode 安装插件 Live Server 不然会报错
html页面右键打开Open With Live Server
**新建test.html a.js b.js**
**1、a.js**
export function aa() {
console.log('module aa test === ')
}
**2、b.js**
import { aa } from './a.js'
aa()
function bb() {
console.log('==== ', aa())
}
bb()
**3、html引入关键词type=module**
<script src="./js/b.js" type="module"></script>
或者单个多个模块
<script type="module">
import { bb } from './js/b.js'
import { cc } from './js/cc.js'
import { dd } from './js/dd.js'
bb()
cc()
dd()
</script>
html 原生 js 模块 导入 导出
于 2023-07-21 11:58:55 首次发布