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