v-html 中的样式覆盖

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/,如果用 >>>也不生效

posted @ 2023-11-22 09:08  今天代码写完了吗  阅读(23)  评论(0编辑  收藏  举报