大佬教程收集整理的这篇文章主要介绍了css-styleUrls没有加载到angular2 ChildComponent(RC5)中,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
博客中没有404,chrome的开发工具不会将chapter.css显示为源,或网络上存在的东西.@H_874_3@
在这里,您可以看到导致我出现此问题的组件:@H_874_3@
@Component({ SELEctor: 'chapter',template: `<div [innerHTML]="content"></div>`,styleUrls: ['app/tutorial/chapter/chapter.css'] }) export class chapterComponent implements OnInit,OnDestroy { private sub: Subscription; private content: String = ''; constructor( private route: ActivatedRoutE) { } ngOnInit() { this.sub = this.route.params.subscribe(params => { var that = this; var _url = './chapter/' + params['id'] + '.html'; $.ajax({ url: _url,success: function (result) { that.content = result; } }); }); } }
chapter.css没有被选中……你可以在这里看到我的项目文件:@H_874_3@
|-- error.html',|-- index.html',|-- app',|-- app.component.ts',|-- app.module.ts',|-- app.routes.ts',|-- main.ts',|-- home',| |-- home.component.ts',| |-- home.css',| |-- home.html',|-- tutorial',|-- tutorial.component.ts',|-- tutorial.css',|-- tutorial.html',|-- tutorial.module.ts',|-- tutorial.routes.ts',|-- chapter',|-- chapter.component.ts',|-- chapter.css',|-- chapter.html',
为什么只有这个组件不起作用…我能看到的唯一区别是这个组件是一个子组件,所以也许这有所不同?@H_874_3@
更新:@H_874_3@
正如对答案的评论中所述,使用路径./app/tutorial/chapter/chapter.css可以在教程组件中使用,但完全相同的路径在章节组件(子组件)中不起作用.我还添加了ViewEncapsulation,但它不起作用……@H_874_3@
以上是大佬教程为你收集整理的css-styleUrls没有加载到angular2 ChildComponent(RC5)中全部内容,希望文章能够帮你解决css-styleUrls没有加载到angular2 ChildComponent(RC5)中所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。