Home  >  Article  >  Web Front-end  >  How to modify the port number in vue project

How to modify the port number in vue project

WBOY
WBOYOriginal
2022-04-08 16:41:2227425browse

Method: 1. Modify the "port" item in the "config\index.js" folder. "port" means the port number. This method can permanently modify the VUE project startup port number; 2 , use "module.exports={devServer:{port:port number,}" to modify.

How to modify the port number in vue project

The operating environment of this article: Windows 10 system, Vue version 2.9.6, DELL G3 computer.

How to modify the port number in vue project

1.Vue 2.x

There is an index.js in the config folder, part of which is as follows, port That is the port number, you can change it here.

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,
   }
};

How to modify the port number in vue project

2.Vue 3.x

#To modify the port number in Vue 3.x, you need to Create a vue.config.js in the project root directory with the following content.

module.exports = {
  devServer: {
    port: 8080,   // 端口号
  }
};

[Related recommendations: "vue.js tutorial"]

The above is the detailed content of How to modify the port number in vue project. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn