Vue3+TS 问题总结
1、Did you mean to enable the ‘allowJs‘ option
把给提示的文件的script添加lang="ts"
<script lang="ts"></script>
2、[plugin:vite:css] Preprocessor dependency “sass“ not found. Did you install it?
npm install sass --save-dev
3、'RouterOptions' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.
RouterOptions 是一种类型,必须加type形态
import type { RouterOptions } from 'vue-router'
4、使用Vite + Vue3打包后,本地不能直接打开html,会提示css文件和js文件CORS错误
这是由于跨越引起的,需要安装plugin-legacy去处理
npm i @vitejs/plugin-legacy -D
vite.config.js文件
import legacy from '@vitejs/plugin-legacy';
export default defineConfig({
plugins: [
legacy({
targets: ['defaults', 'not IE 11',’Chrome 64’]
}),
vue(),
]