前端Vue项目解决跨域问题

1.在config/index.js:

proxyTable: {
      '/api': {
        target: 'http://192.168.10.000:8066',//api地址
        changeOrigin: true,
        pathRewrite: {
          '^/api': '/'
        }
      }
    },

2.页面使用:

this.$axios.post("/api/signin",loginParams).then(data=>{
    
}).catch(err=>{

})

3.配置完之后重新运行 npm run dev

猜你喜欢

转载自blog.csdn.net/SmartJunTao/article/details/108056769