v-html 中的样式覆盖

发布时间 2023-11-22 09:13:00作者: 今天代码写完了吗

v-html 里 的内容样式如果直接在 style里覆盖样式, 不生效。需要样式穿透才行

<template>
    <div v-html="goodDetails.introduction" class="introduction">
</template>
<style lang="scss" scoped>
.introduction /deep/ img {
	width: 100% !important;
	object-fit: fill;
}
</style>

ps: 注意这里样式穿透用得是 /deep/,如果用 >>>也不生效