ViewEncapsulation.ShadowDom无法正常工作

时间:2019-01-10 11:04:13

标签: angular shadow-dom

我正在使用Angular 7和bootstrap 3.3.7(以便使用glyphicon)。我正在尝试在组件中使用ViewEncapsulation.ShadowDom。但是我收到一个错误“ ERROR DOMException:无法在'Element'上执行'attachShadow':此元素不支持attachShadow”。谁能解释我,为什么我会收到这个错误?

我的ts代码和html代码

 @Component({
  selector: 'favourite',
  templateUrl: './favourite.component.html',
  styleUrls: ['./favourite.component.css'],
  encapsulation: ViewEncapsulation.ShadowDom
})

<span class="glyphicon" 
[class.glyphicon-star]="isSelected"
[class.glyphicon-star-empty]="!isSelected"
(click)="glyphiconClicked()"></span> 

由于ShadowDom是ViewEncapsulation枚举中的新元素,因此我只想查看结果。但是由于该错误,我没有看到任何结果。

1 个答案:

答案 0 :(得分:0)

封装:ViewEncapsulation.ShadowDom

在您的应用程序的Root组件中写上您在Application模块的“ bootstrap:[]”数组或“ entryComponents:[]”数组中提到的行。