首页 > 技术文章 > Vue相关

jingjiu 2020-04-08 16:28 原文

开发环境跨域

  1. 调用接口
 axios({
       method: 'post',
       url: '/api/mserver/rest/ws',
       data: qs.stringify(requestData)
      })
  1. vue.config.js文件配置
module.exports = {
  publicPath: '/healthRecords',
  outputDir: 'healthRecords',

  devServer: {
    proxy: {
      '/api': {
        // 调用接口的域名和端口
        target: "http://218.75.139.90:10080",
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        }
      }
    }
  }
}

推荐阅读