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
coldplay.xixiOriginal
2020-11-10 16:11:093635browse

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

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 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!

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