学习angular5。当我使用的角度CLI来创建新的组件,我得到了下面的代码:带CLI的角度创建组件提供封装:ViewEncapsulation.None
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-example',
templateUrl: './example.component.html',
styleUrls: ['./example.component.css'],
encapsulation: ViewEncapsulation.None
})
export class ExampleComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
然而encapsulation: ViewEncapsulation.None
使得代码休息,扑灭了以下错误消息:
我知道如何通过删除encapsulation: ViewEncapsulation.None
来修复该错误。然而,有没有办法不把这行代码放在第一位?
您是从'@ angular/core'导入'ViewEncapsulation'吗? –