【发布时间】:2019-10-26 17:13:54
【问题描述】:
我尝试了三种方法。
第一个:index.html
<base href="/customer">
第二个:app.module.ts
@NgModule({
providers: [{provide: APP_BASE_HREF, useValue: '/customer'}]
})
第三个:app-routing.module.ts
const routes: Routes = [
{ path: "", redirectTo: "/customer", pathMatch: "full" },
{
path: "customer",
component: CustomerComponent,
data: { animation: "HomePage" }
}
];
上述所有方法都适用于 URL 路由,我得到了所需的 URL。
http://localhost:4200/customer
但是,静态文件(js 和图像)仍在使用基本路径“http://localhost:4200/”加载。我需要它像http://localhost:4200/customer/main.js。
因此,出于某些安全验证原因,我尝试将其设为 http://localhost:4200/customer/main.js 而不是 http://localhost:4200/main.js。
在下面的截图中可以看到。
【问题讨论】:
标签: angular angular7 angular-routing angular7-router