【发布时间】:2017-09-19 10:42:38
【问题描述】:
我是 Angular 的新手,我正在尝试在 Visual Studio 代码中调试代码。对于调试,我使用 Chrome 的扩展调试器,配置如下:
**launch.json**
{
"version": "0.2.0",
"configurations": [
{
"name": "ng serve",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200/#",
"webRoot": "${workspaceRoot}"
},
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"url": "http://localhost:9876/debug.html",
"webRoot": "${workspaceRoot}"
},
{
"name": "ng e2e",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/protractor/bin/protractor",
"protocol": "inspector",
"args": ["${workspaceRoot}/protractor.conf.js"]
}
]
}
它工作正常。但是我有环境问题。我有 3 种不同的环境。在 environemnt.ts 我有到 localhost 的路由,接下来的两个是服务器上的 api,例如 environemnt.tst1.ts 和 environemnt.tst2.ts。
如果我想通过 Angular cli 执行某些环境,没关系。我写了 ng serve --env=ts 并针对环境 ts1 工作。但是如果我想调试。我必须写 npm start (这是调试模式的条件),它会生成以下代码:
npm start
> web-client@0.0.0 start C:\GitProjects\web-client
> ng serve --host 0.0.0.0 --port 4200
但它适用于基本环境。ts
我的问题是,我该如何选择另一个环境。我正在尝试 f.e.有些人在配置文件中添加参数env,值为ts1,但它写的是mi,不允许使用Property env。
你有解决这个问题的经验吗?
谢谢。
【问题讨论】:
标签: angular debugging visual-studio-code