webpack之proxyTable配置


有兩種情況:

一,有統一的項目名

config下index.js

配置如下:

    proxyTable: {
      '/tbt_user':{
        target: 'http://47.98.216.251:80', //測試線
        changeOrigin: true, // 是否跨域
        pathRewrite: {
          '^/tbt_user': '/tbt_user'
        }
      }

頁面接口調用

    this.$axios.post('/tbt_user/third/pay/query').then((response) => {
      console.log(response)
    }).catch(err => {
      console.log('err')
      console.log(err)
    })

 

二,沒有統一項目名

    proxyTable: {
      '/api':{
        target: 'http://47.94.142.215:8082', // 測試
        changeOrigin: true, // 改變源(是否跨域)
        pathRewrite: {
          '^/api': '/'
        }
      }
    }

頁面調用:

    this.$axios.post('/api/third/pay/query').then((response) => {
      console.log(response)
    }).catch(err => {
      console.log('err')
      console.log(err)
    })

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM