script之type=module
type module script
2023-09-11 14:19:18 时间
专栏目录请点击
- 在远古时代,我们引入js文件一般使用
<script src='路径'>
来引入其他的js文件,但是随着js的规范化和模块化,在模块与模块之间的引入往往用import
- 想要实现这种效果,我们可以在
script
上增加一个type='module'
实例
目录
代码
script_model.html
<!DOCTYPE html>
<html lang="en">
<body>
<script type="module">
import {sayHello} from "./index.js"
sayHello()
</script>
</body>
</html>
index.js
export const sayHello = () => {
console.log("Hello")
}
这样我就就会发现我们医用使用import
来进行引入数据了
相关文章
- [Typescript] Key in union type
- [Typescript] User defined type guards
- [Javascript] Correctly Type-Checking Numbers
- [Typescript] Tips: Turn a module into a type
- [Compose] 20. Principled type conversions with Natural Transformations
- ABAP 数据字典里数据元素(Data Element),结构(Structure)和表类型(Table Type)三者的使用辨析试读版
- 2015-03-17 how is task transaction type retrieved
- 前后端分离 导致的 静态页面 加载 <script type="module" > 报CORS 跨域错误,提示 blocked by CORS policy
- Content type ‘application/x-www-form-urlencoded;charset=UTF-8‘ not supported错误的多种解决方法及说明Content-Type
- JSON parse error: Cannot deserialize value of type `java.lang.Integer` from Boolean value
- Python标准库:内置函数super([type[, object-or-type]])
- 电路方案分析(八)Type-C 端口短路保护参考设计
- 【异常】解决 Cannot find module ‘./element-ui‘ or its corresponding type declarations.