ValidationError: webpack Dev Server Invalid Options options should NOT have additional properties

出现上述错误是因为给vue了无效的配置。原因就是我使用的是vue/cli4但使用了proxyTable进行配置。注意cli2下用的是proxyTable加上一系列配置,cli3及以上用的是proxy。

vue-V查看vue/cli的版本

使用vue.config.js解决代理问题。首先在根目录下创建 vue.config.js(注意检查不要创建在src文件夹下)。然后通过配置代理如下。

// vue.config.js
module.exports = {
    runtimeCompiler: true,
    publicPath: '/', //设置打包路径
    devServer: {
        port: 8081,
        host: 'localhost',
        open: true,
        https: false,
        proxy: {
          '/api/*': {
              target: 'http://127.0.0.1:8082',
              changeOrigin: true,
              pathRewrite: {
                  '^/api': ''
              }
          }
        }
    }
}

你可能感兴趣的:(vue错误笔记,vue,前端框架)