脚本宝典收集整理的这篇文章主要介绍了vue项目怎么修改端口号,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
方法:1、修改“config\index.js”文件夹中的“port”项内容即可,“port”就表示端口号,该方法能够永久修改VUE项目启动端口号;2、利用“module.exports={devServer:{port:端口号,}”修改。
本文操作环境:windows10系统、Vue2.9.6版,DELL G3电脑。
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, // 端口号 } };
【相关推荐:《vue.js教程》】
以上就是vue项目怎么修改端口号的详细内容,更多请关注脚本宝典其它相关文章!
以上是脚本宝典为你收集整理的vue项目怎么修改端口号全部内容,希望文章能够帮你解决vue项目怎么修改端口号所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。