在package.json上设置:
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.config.json --host 10.1.1.152",
"build": "ng build --prod --aot",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
把start启动项的内容后加--host 服务器IP地址;
访问时就可以10.1.1.152:4200直接访问了
本文介绍如何在Angular项目的package.json中配置启动项,通过添加--host参数指定服务器IP地址,实现项目部署后可通过特定IP访问。具体步骤包括在scripts字段下修改start指令,加入--proxy-configproxy.config.json及--host参数。

617

被折叠的 条评论
为什么被折叠?



