webpack-dev-server配置

Vue-cli2
config/index.js

只要在dev环境下请求/api,就会被转发到http://localhost:8080/static/mock

module.export {
  dev: {
        proxyTable: {
            '/api': {
                     target: 'http://localhost:8080',
                     pathRewrite: {
                        "^/api": ''/static/mock"
                     } 
             }
        }
    }
}

猜你喜欢

转载自blog.csdn.net/qq_38402659/article/details/87970401