记录:遇到的问题,以及解决的方法
1.@别名问题
通过path模块下的join设置别名时
//vite.config.ts
import { join } from "path"
resolve: {
alias: {
"@": join(__dirname, "./src")
}
}
解决:下载依赖 yarn add `@types/node` -D
注:其他依赖ts版本都是下载 yarn add @types/xxx -D
2.使用@别名时
在使用时报红
import Login from "@/views/Login.vue"
解决: 在tsconfig.json下添加
compilerOptions:{
...,
/* URLs */
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},
}
3.在ts文件中使用ELEMENT-PLUS框架时
会提示找不到
解决: 在tsconfig.json下添加
"include":[...,"auto-imports.d.ts"]
4.引入vue时爆红,称找不到
Cannot find module 'vue'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?
//tsconfig.json
compilerOptions:{
...,
"moduleResolution": "node",
}