vue.js怎么改端口号

coldplay.xixi
coldplay.xixi 原创
2020-11-30 15:43:51 3058浏览

vue.js更改端口号的方法:1、config文件夹中有一个【index.js】其中部分内容如下,port即为端口号,在这里更改;2、【Vue 3.x】中修改端口号则需要在项目根目录下创建一个【vue.config.js】。

本教程操作环境:windows10系统、vue2.9,本文适用于所有品牌的电脑。

【相关文章推荐:vue.js

vue.js更改端口号的方法:

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,   // 端口号
  }
};

相关免费学习推荐:JavaScript(视频)

以上就是vue.js怎么改端口号的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。