Vue项目启动默认打开http://0.0.0.0:8080,浏览器显示无法访问,手动修改为 localhost:8080 可正常打开
vue-cli 5.x 版本 使用–open 时,默认打开浏览器,会出现0.0.0.0:8080,浏览器显示无法访问,手动修改为 localhost:8080 可正常打开,但是每次都需要修改就很烦人。
解决办法:
在vue.config.js文件新增:
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
devServer: {
open: true,
host: 'localhost',
port: 8080
}
})