1. 找到vue.config.js
module.exports = {
  productionSourceMap: false,
  configureWebpack: {
    devServer: {
      proxy: {
        '/api': {
          target: 'http://localhost:8090', //设置调用的接口域名和端口号(默认端口号80)
          changeOrigin: true, //
          pathRewrite: {
            '^/api': ''
          }
               //这里理解成用‘/api’代替target里面的地址,
              //后面组件中我们掉接口时直接用api代替 
              //比如我要调用'http://40.00.100.100:3002/user/add',
              //直接写‘/api/user/add’即可
        }
      }
    }
  },
  lintOnSave: false
}

  1. 调用实例
  this.$axios
                .get("api/assetPricing/findAll", {
                    params: {},
                })
                .then(res => {
                    // if (res.data.Code == 0) {
                    //     if (res.data.Status == null) {
                    //         this.items = []
                    //     } else {
                    //         this.items = res.data.Status
                    //     }
                    // }
                   window.console.log(res.data);
                })

相关文章:

  • 2021-12-26
  • 2021-12-06
  • 2021-12-24
  • 2021-11-29
  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-04
  • 2022-12-23
  • 2022-01-01
  • 2022-03-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案