|
@@ -1,23 +1,27 @@
|
|
|
# Vue 3 + TypeScript + Vite
|
|
# Vue 3 + TypeScript + Vite
|
|
|
|
|
|
|
|
-## js文件下载
|
|
|
|
|
|
|
+### js文件下载
|
|
|
https://blog.csdn.net/weixin_41217541/article/details/109893272?spm=1001.2101.3001.6650.5&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-5-109893272-blog-112007458.pc_relevant_aa&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-5-109893272-blog-112007458.pc_relevant_aa&utm_relevant_index=10
|
|
https://blog.csdn.net/weixin_41217541/article/details/109893272?spm=1001.2101.3001.6650.5&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-5-109893272-blog-112007458.pc_relevant_aa&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-5-109893272-blog-112007458.pc_relevant_aa&utm_relevant_index=10
|
|
|
|
|
|
|
|
|
|
|
|
|
-## js 下载
|
|
|
|
|
|
|
+### js 下载
|
|
|
https://blog.csdn.net/weixin_43299180/article/details/112007458
|
|
https://blog.csdn.net/weixin_43299180/article/details/112007458
|
|
|
|
|
|
|
|
|
|
|
|
|
## 只刷新一次页面
|
|
## 只刷新一次页面
|
|
|
-if (location.href.indexOf("#reloaded") === -1) {
|
|
|
|
|
|
|
+`if (location.href.indexOf("#reloaded") === -1) {
|
|
|
location.href = location.href + "#reloaded";
|
|
location.href = location.href + "#reloaded";
|
|
|
location.reload();
|
|
location.reload();
|
|
|
-}
|
|
|
|
|
|
|
+}`
|
|
|
|
|
|
|
|
## vite + vue3 低版本浏览器兼容配置
|
|
## vite + vue3 低版本浏览器兼容配置
|
|
|
-1. 安装兼容插件 yarn add @vitejs/plugin-legacy
|
|
|
|
|
|
|
+1. 安装兼容插件
|
|
|
|
|
+`
|
|
|
|
|
+yarn add @vitejs/plugin-legacy
|
|
|
|
|
+`
|
|
|
2. vite.config.ts 中引入
|
|
2. vite.config.ts 中引入
|
|
|
- import legacy from '@vitejs/plugin-legacy'
|
|
|
|
|
|
|
+`
|
|
|
|
|
+import legacy from '@vitejs/plugin-legacy'
|
|
|
plugins:[
|
|
plugins:[
|
|
|
legacy({
|
|
legacy({
|
|
|
targets: ['chrome 50', 'ie >= 11'], //兼容最低版本号50(UC浏览器55)
|
|
targets: ['chrome 50', 'ie >= 11'], //兼容最低版本号50(UC浏览器55)
|
|
@@ -46,8 +50,9 @@ if (location.href.indexOf("#reloaded") === -1) {
|
|
|
modernPolyfills: ['es.string.replace-all']
|
|
modernPolyfills: ['es.string.replace-all']
|
|
|
})
|
|
})
|
|
|
]
|
|
]
|
|
|
-
|
|
|
|
|
|
|
+`
|
|
|
|
|
|
|
|
## vite打包时会报错
|
|
## vite打包时会报错
|
|
|
-terser not found. Since Vite v3, terser has become an optional dependency. You need to install it.
|
|
|
|
|
-## 解决办法:yarn add terser --legacy-peer-deps 再重新打包
|
|
|
|
|
|
|
+`terser not found. Since Vite v3, terser has become an optional dependency. You need to install it.`
|
|
|
|
|
+## 解决办法:
|
|
|
|
|
+`yarn add terser --legacy-peer-deps 再重新打包`
|