twitter-bootstrap-3 – bootstrap类未应用于角度2组件
发布时间:2020-12-18 00:05:28 所属栏目:安全 来源:网络整理
导读:这是我的第一个有角度的2应用程序,不知道为什么没有应用bootstrap类或者缺少glyphicons?有人可以解释如何在角度2中使用bootstrap类吗? 这是我的app.component.ts import {Component} from 'angular2/core';import {LikeComponent} from './like.component'
这是我的第一个有角度的2应用程序,不知道为什么没有应用bootstrap类或者缺少glyphicons?有人可以解释如何在角度2中使用bootstrap类吗?
这是我的app.component.ts import {Component} from 'angular2/core'; import {LikeComponent} from './like.component' @Component({ selector: 'my-app',template: ` <like [totalLikes]="tweet.totalLikes" [iLike]="tweet.iLike"></like> `,directives: [LikeComponent] }) export class AppComponent { tweet = { totalLikes: 10,iLike: false } } 和like.component.ts: import {Component,Input} from 'angular2/core'; @Component({ selector: 'like',template: ` <i class="glyphicon glyphicon-heart" [class.highlighted]="iLike" (click)="onClick()"> </i> <span>{{ totalLikes }}</span> `,styles: [` .glyphicon-heart { color: #ccc; cursor: pointer; } .highlighted { color: deeppink; } `] }) export class LikeComponent { @Input() totalLikes = 0; @Input() iLike = false; onClick(){ this.iLike = !this.iLike; this.totalLikes += this.iLike ? 1 : -1; } } 解决方法
实际上问题是你没有在主文件中导入Bootstrap.css文件,即index.html文件,
尝试在index.html中使用此核心引导程序文件运行, 在index.html中导入此文件: – <link data-require="bootstrap-css@3.3.6" data-semver="3.3.6" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css" /> 这是您的代码Working Plunker的工作示例 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |