Vue.config.js configuration error ValidationError: Invalid options object

image.png

This error message means that the Dev Server has been initialized using an option object that does not match the API mode. It clearly states that it is an attribute disableHostCheck, so I blocked this attribute and found that it can be started successfully.

At this time, I checked the webpack versions of the previous and this project and found that this time the version was webpack5 and the previous version was webpack4. I also checked the webpack documentation and found that

image.png

disableHostCheckThis attribute has been deleted and replaced in webpack4. This attribute no longer exists in webpack5, so an error will be reported when configuring this. The correct way is to replace it withallowedHosts

javascript const { defineConfig } = require('@vue/cli-service') module.exports = defineConfig({ //基本路径 publicPath: process.env.NODE_ENV === 'production' ? './' : '/', //输出目录 outputDir: 'dist', //指定生成的文件 indexPath: 'index.html', //vue兼容ie transpileDependencies: true, //是否启用eslint验证 lintOnSave: false, //开发环境配置 devServer: { //允许别人访问自己的ip地址 host: '0.0.0.0', allowedHosts: "all", //代理配置 proxy: { '/api': { target: 'https://192.168.x.xxx:8080/',//接口的域名 ws: true,//是否代理websockets secure: false,//是否是https接口 changeOrigin: true,//是否跨域 pathRewrite: {//重写地址,将前缀/api转为"" '^/api': "" } } } } })

Mobile display configurationhtml <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />

Guess you like

Origin blog.csdn.net/qq_40591925/article/details/132974427