方法:1、修改“configindex.js”文件夾中的“port”項內(nèi)容即可,“port”就表示端口號,該方法能夠永久修改VUE項目啟動端口號;2、利用“module.exports={devServer:{port:端口號,}”修改。
本文操作環(huán)境:windows10系統(tǒng)、Vue2.9.6版,DELL G3電腦。
vue項目怎么修改端口號
1.Vue 2.x
config文件夾中有一個index.js其中部分內(nèi)容如下,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中修改端口號則需要在項目根目錄下創(chuàng)建一個vue.config.js,內(nèi)容如下。
module.exports = { devServer: { port: 8080, // 端口號 } };
【