作者:景科儒_189 | 来源:互联网 | 2023-02-01 17:56
我们的角度应用程序将在生产时嵌入到iframe中.在开发中,我们有一个文件host.html,它有一个iframe,其src是angular app的索引页面.我们可以'服务',然后手动调出host.html,它工作正常.
但是,'ng serve -o'想要打开app索引文件; 我如何让它打开host.html而不是?
1> John..:
因此我不认为angular cli支持使用该-o
选项打开任意页面,但您可以创建自己的npm
脚本来执行您想要的操作.
尝试打开package.json
并编辑该scripts
部分以更新start
脚本(mac版本):
"scripts": {
"ng": "ng",
// where localhost:4200 is your dev host and port, respectively
"start": "ng serve && open http://localhost:4200/host.html",
"build": "ng build",
...
},
根据您使用的平台,脚本需要以不同的方式编写:
// Windows
"start":"ng serve & start http://localhost:4200/host.html"
// Mac
"start":"ng serve && open http://localhost:4200/host.html"
// Linux
"start":"ng serve && xdg-open http://localhost:4200/host.html"
然后,使用,而不是使用ng serve
启动您的应用程序npm start
.
参考:针对平台特定命令使用此SO答案open
.