在项目开始编写后,Vue.js初配置时可能会出现神奇报错,这时只需要关闭语法检查即可。
在 vue.config.js 文件中配置如下代码:
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
lintOnSave: false//关闭语法检查
})
在 vue.config.js 文件中可以先配置代理API,设置跨域请求。
module.exports = {
lintOnSave: false, //开启语法检测
devServer: {
//host: "localhost",
//port: 8081, // 端口号
https: false, // https:{type:Boolean}
open: true, //配置自动启动浏览器
proxy: {
"/api": {
//代理api
target: "http://192.168.1.56:8081/m.api", //服务器api地址
ws: true, // proxy websockets
changeOrigin: true, //是否跨域
pathRewrite: {
//重写路径
"^/api": ""
}