在package.json文件中修改start项的内容,增加--open或-o标签
如下操作
"scripts": {
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor",
"hmr": "ng serve --host 0.0.0.0 --port 4200 --hmr",
"lint": "tslint --force --project src/tsconfig.json src/**/*.ts -t verbose",
"ng": "ng",
"start": "ng serve --host 0.0.0.0 --port 4200 --open",
"test": "ng test"
},
或者
"scripts": {
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor",
"hmr": "ng serve --host 0.0.0.0 --port 4200 --hmr",
"lint": "tslint --force --project src/tsconfig.json src/**/*.ts -t verbose",
"ng": "ng",
"start": "ng serve --host 0.0.0.0 --port 4200 -o",
"test": "ng test"
},
方式二:
在启动命令后面直接加上--open或-o标签
如(以yarn启动为例)
yarn start --open
yarn start -o
ps:可在后面加上--port 更改启动端口号 如 -- yarn start -o --port 4300