vue-cli3 配置跨域並通axios進行數據請求


在項目根目錄下創建vue.config.js文件,配置信息:

module.exports = {
    devServer: {
        proxy: {
            '/api': {
                target: 'http://192.168.0.8:9090',
                changeOrigin: true,
                ws: true,
                pathRewrite: {
                    '^/api': ''
                }
            },
        }
    }
}
this.$axios.get('/api/users/search',{params:this.searUser})
                .then(res => {
                    this.loading = false;

                    this.tableData = res.data.records;

                }).catch(err => {
                    this.loading = false;
                    this.$message.error(err);
                });

 


免責聲明!

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



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