2:先跑起来看是否异常,如果没有跑起来我们可以检查分析nginx的log日志
3:项目路径如下:
4:前端多环境简单测试配置
5:路由配置简单测试数据
const routes: Routes = [ { path: '', redirectTo: '/home', pathMatch: "full" }, { path: "home", component: HomeComponent, children: [ { path: "top", component: TopComponent }, { path: "menu", component: MenuComponent, children: [ { path: "body", component: BodyComponent }, ] }, { path: "product", component: ProductComponent }, ] }, { path: "**", redirectTo: "menu" } ];
6:服务code如下,或者在组件中使用
import { Injectable } from '@angular/core'; import { environment } from '../../environments/environment'; @Injectable({ providedIn: 'root' }) export class MyenviromentService { constructor() {} getEnviromentApiurlData(){ return environment.apiUrl; } }
7:不同环境配置code
8:在一个组件中使用打印显示出当前的环境参数
9:测试结果截图
10:小结:操作步骤原理就是:ngin跑起来先,配置好不同环境的接口网关参数等,然后就是在页面上显示出来,方便自己查看环境配置是否ok,最后将打包好的前端code给到nginx运行即可
标签:code,环境,component,environment,nginx,path,Angular,打包 From: https://www.cnblogs.com/Fengge518/p/18216088