vue3-vite
宁静致远 7/18/2020 vue3
- 前端构建工具、提升前端开发体验
- 开发环境使用ES6 Module 无需打包、启动快
- 生产环境使用rollup, 并不会快很多
本地使用
<script type="module"></script>
外链
<script type="module" src="./src/index.js"></script>
远程引入
import { zzz } from 'https://xxx.com/yyy.js'
动态引入
async await import('./src/add.js') res.default 获取
<!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>
</head>
<body>
<script type="module">
import add from './add.js';
const res = add(10,20)
console.log('res, ', res);
</script>
</body>
</html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import print from './print.js';
function add(a, b) {
return a + b
}
export default add
1
2
3
4
5
2
3
4
5