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

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

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);
                });
相關文章
相關標籤/搜索