寫手在作畫的夜晚,留下路人驚嘆
在3.0中需要手動創建vue.config.js文件來進行配置
安裝:
npm install --save-dev http-proxy-middleware
module.exports = {
// baseUrl: "/", 3.0中baseUrl廢掉了
publicPath: "/live/", 公共文件夾
outputDir: "public/live",//打包后存放靜態資源的文件夾( 指定一下 )
devServer: { //自動打開瀏覽器
port: "8080",
host: "localhost",
open: true,
看這里
proxy: {
"/api": {
target: "", //要跨域的域名 目標地址
changeOrigin: true, //是否開啟跨域 是否更改源路徑
ws: true,
pathRewrite: {
"^/api": "" // /api/ / 凡是/api開頭的地址都可以跨域
}
}
}
}
};