Skip to content

Vue 中的样式无法应用到 v-html 渲染的 DOM 中 #167

@Dream4ever

Description

@Dream4ever

解决过程

在开发一个功能的过程中,发现用 Vue 写的项目,scoped 的样式默认是无法应用到 v-html 渲染的 DOM 中的。

Google vue v-html css not working 之后,在 CSS styles not being applied to HTML within a Vue Component 这篇问答中找到了解决方案,原来是要用 Deep Selectors/深度作用选择器 才能解决这个问题。

测试了 .a >>> .b.a /deep/ .b.a ::v-deep .b 三种方式,只有最后一种方式生效。

Metadata

Metadata

Assignees

No one assigned

    Labels

    CSSThe world is beautifulVuePowerful framework

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions