The browser in the vue project opens automatically, and a page error occurs at 0.0.0.0:8080

1. In the vue project, enter the command line npm run serve browser to automatically open the function, you need to add --open in the configuration file (package.json)

2. After the browser is automatically opened, there may be an error on the URL 0.0.0.0:8080 page, as shown in the figure

 3. Solution:

Original code:

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true
})

Add the following code to the vue.config.js configuration file:

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    host: 'localhost',
    port: 8080,
  }
})

4. Re-enter npm run serve on the command line, and the browser can be opened normally and automatically

Guess you like

Origin blog.csdn.net/m0_64351096/article/details/126982231