angular 中的 environments文件夹有两个文件environment.ts ,environment.prod.ts 分别对应开发模式,生产模式
- 在 environment.ts 追加 url:http:development :1234/project
- 在 environment.prod.ts 追加 url:http:production :8080/project
在app.component.ts中加入
import { environment } from './../environments/environment'
console.log(environment.url);
开发模式:
environment.ts = development mode = 开发环境 实际开发
ng serve --open
前台显示:http:development :1234/project
打包 ng build --prod
生产模式
environment.prod.ts = production mode = 生产环境 生产中产生效益(个人理解)
ng serve --configuration=production --open
前台显示:http:production :8080/project
打包 ng build --configuaration=production --prod