1.Vue 2.x
config文件夾中有一個index.js
其中部分內容如下,port
即為端口號,在這里更改即可。
module.exports = { dev: { env: require('./dev.env'), port: 8080, // 端口號 assetsSubDirectory: 'static', assetsPublicPath: '/', proxyTable: {}, // CSS Sourcemaps off by default because relative paths are "buggy" // with this option, according to the CSS-Loader README // (https://github.com/webpack/css-loader#sourcemaps) // In our experience, they generally work as expected, // just be aware of this issue when enabling this option. cssSourceMap: false, } };
2.Vue 3.x
Vue 3.x中修改端口號則需要在項目根目錄下創建一個vue.config.js
,內容如下。
module.exports = { devServer: { port: 8080, // 端口號 } };
3.起因
Access to XMLHttpRequest at 'http://localhost:8080/sockjs-node/info?t=1565711501046' from origin 'http://192.168.0.104:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
localhost:8080/sockjs-node/info?t=1565711501046:1 Failed to load resource: net::ERR_FAILED
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com