vue项目运行后如何自动在浏览器中打开

方法一:配置open

在根目录webpack.config.js或vue.config.js中的module.exports里面配置devServer / open,将open属性值设置为true即可

 devServer: {
    host: 'localhost',
    port: 9000, // 端口号
    open:true, //运行后是否自动在浏览器打开
  },

方法二:配置transpileDependencies

第一步:在根目录webpack.config.js或vue.config.js中的module.exports里面配置transpileDependencies

transpileDependencies: true,//运行后是否自动在浏览器打开

第二步:在package.json中的scripts / serve 或 scripts / dev 的属性值后面加上 --open

"serve": "vue-cli-service serve --open",

猜你喜欢

转载自blog.csdn.net/weixin_44594219/article/details/126700897