1

我有一个侧边栏菜单脚本文件,位于我包含到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 文件?

4

2 回答 2

0

您可以在 angular.json 文件中添加外部脚本和样式,例如

"styles":[ 
"src/assets/css/style.css"
],
"scripts"[
"src/assests/js/script.js"
]
于 2018-09-26T11:34:46.277 回答
0
"styles":[ 
"/style.css"
],

"scripts"[
"src/script.js"
]

如果您使用 CDN,也可以将其添加到 index.html。

于 2018-09-27T07:24:12.660 回答