开启 proxyTable,注意此方法只能在开发环境起作用,build之后的项目依然无法跨域,后面会介绍修改apache/nginx的url重写(或反向代理)实现跨域。 此方法以 vue脚手架生成的标准项目为准。一般在项目config目录下面有个index文件。里面格式如下: 'use strict' // Template version: 1.3.1 // see http://vuejs-templates.github.io/webpack for documentation. const path = require('path') module.exports = { dev: { // Paths assetsSubDirectory: 'static', assetsPublicPath: '/', proxyTable: { '/api': { target:'http://www.test.com:8080',//不填端口将默认80 // secure: false, // ...