Home > Web Front-end > Vue.js > How to change the port number in vue.js

How to change the port number in vue.js

coldplay.xixi
Release: 2020-11-30 15:43:51
Original
3644 people have browsed it

How to change the port number in vue.js: 1. There is an [index.js] in the config folder, part of which is as follows, port is the port number, change it here; 2. [Vue 3.x ] To modify the port number, you need to create a [vue.config.js] in the project root directory.

How to change the port number in vue.js

The operating environment of this tutorial: windows10 system, vue2.9, this article is applicable to all brands of computers.

【Recommended related articles: vue.js

How to change the port number in vue.js:

1.Vue 2.x

There is an index.js in the config folder, part of which is as follows, port 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,
   }
};
Copy after login

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

Related free learning recommendations: JavaScript (video)

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template