1.运行文件,让浏览器自动打开
我们平时要运行文件,那么就需要在cmd命令行指令当中输入npm run serve,然后再在浏览器当中输入端口号,但是不能直接显示在页面上。那么这个时候就需要在package.json当中配置:
"scripts": { "serve": "vue-cli-service serve --open",//在后面加上一个 --open 那么就可以直接渲染到页面上啦 "build": "vue-cli-service build" },
2.eslint校验功能关闭(防止代码检验冲突)
在vue.config.js代码当中加入:
module.exports = defineConfig({ lintOnSave:false })
3.src文件夹间写方法:配置别名
解决方法:
在tsconfig.js或者新建一个jsconfig.js文件,在里面配置
A.但是在本机电脑创建vue文件的时候,已经配置了一点点,就只需要在
"exclude": [
"node_modules","dist"
]当中加入"dist"
B.然后将"baseUrl": "./"路径改为“./”
C."paths": {
"@/*": [
"src/*"
]不变
{ "compilerOptions": { "target": "esnext", "module": "esnext", "strict": true, "jsx": "preserve", "moduleResolution": "node", "experimentalDecorators": true, "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, "useDefineForClassFields": true, "sourceMap": true, "baseUrl": "./", "types": [ "webpack-env" ], "paths": { "@/*": [ "src/*" ] }, "lib": [ "esnext", "dom", "dom.iterable", "scripthost" ] }, "include": [ "src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "tests/**/*.ts", "tests/**/*.tsx" ], "exclude": [ "node_modules","dist" ] }