const port = process.env.port || process.env.npm_config_port || 80
module.exports = defineConfig({
devServer: {
port: port,
open: {
target: [`http://localhost:${port}`]
},
}
})
结果:ip和localhost都能访问,并且程序启动后 为 http://localhost:80