vue项目中浏览器自动打开,出现网址0.0.0.0:8080页面错误

1、在vue项目中,输入命令行  npm run serve   浏览器实现自动打开功能,需要添加 在配置文件(package.json)中添加 --open

2、浏览器自动打开后,可能会出现网址0.0.0.0:8080页面错误,见图

 3、解决方法:

原代码:

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

在 vue.config.js 配置文件中添加以下代码:

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

4、命令行 重新输入 npm run serve   浏览器就可以正常自动打开

扫描二维码关注公众号,回复: 16004368 查看本文章

猜你喜欢

转载自blog.csdn.net/m0_64351096/article/details/126982231