根目錄新建 vue.config.js文件:
添加如下代碼:
1 module.exports = { 2 outputDir: 'dist', //build輸出目錄 3 assetsDir: 'assets', //靜態資源目錄(js, css, img) 4 lintOnSave: false, //是否開啟eslint 5 devServer: { 6 open: true, //是否自動彈出瀏覽器頁面 7 host: "localhost", 8 port: '8081', 9 https: false, 10 hotOnly: false, 11 proxy: { 12 '/api': {14 target: 'http://erp.f-ev.com/PBaoXFIsvT.php/facrm/analysis', //自己的服務器的地址 15 changeOrigin: true, 16 pathRewrite: { 17 '^/api': '' 18 19 } 20 } 21 } 22 } 23 }
然后請求寫法 URL前綴加上api即可:
this.$axios({
method: 'post',
url: '/api/Kpi/selectpage_yunying',
}).then((res) => {
if (res.data.code == "200") {
}
});
到此結束!