【发布时间】:2018-09-17 06:14:57
【问题描述】:
我有一个侧边栏菜单脚本文件,位于我包含在index.html 中的资产文件夹中。每当我刷新 home/dashboard 子路由时,脚本都会运行,如果我从初始路由 / 重定向到 home/dashboard,侧边栏显示/隐藏按钮不起作用(此逻辑是脚本的一部分,我提到)一旦我刷新页面,外部脚本将正常工作。这是我的路由模块
app.routing.module.ts
const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full' },
//{ path: 'login', component: LoginComponent, },
{ path: 'home', component: HomeComponent,
children:[
{ path: '', redirectTo: 'dashboard', pathMatch: 'full' },
{ path: 'dashboard', component: DashboardComponent,},
{ path: 'totalapproved', component: ApprovedComponent,},
{ path: 'campaign', component: CampaignmanagerComponent,},]}
]
有没有办法将外部资产脚本添加到 angular.json 文件中?
【问题讨论】:
-
分享更多细节并正确陈述您的问题。无法准确理解您想要什么。
-
准确理解您的问题有点困难,但我认为您的问题是我们的外部脚本只会在初始页面加载时执行。因此,如果您刷新页面,然后导航到子路由,那么它们将不起作用。这是正常行为
标签: angular angular2-routing angular6 angular-router app-route