问题描述
我正在 angular 中创建富文本编辑器,当我执行 document.execCommand('insertOrderedList')
时,我得到 <ol>
项,它不受我组件的 css 的影响,只有 styles.css
中的 css(主 css 文件在项目的根目录)影响我使用 document.execCommand
添加的项目。
是否有可能改变这种行为?
解决方法
当然。它的名字是view encapsulation。将其更改为 ViewEncapsulation.none
会产生所需的行为。
@Component({
...
encapsulation: ViewEncapsulation.none
})