taro+vue3小程序使用v-html渲染的内容为class写了样式无效

taro小程序如果是直接引入的一个less文件是包含scoped,只是当前页面采用。

<script setup>

import './index.less'

</script>

<view v-html="itehtml" class="article-content"></view>

let itehtml="<p class="line2>文字内容太多了如果是超过2行就用省略号</p>"

我发现写在index.less里面根本没有作用。于是在当前页面加了

<style>

/*//只保留两行多余的加省略号*/

.article-content>.line2{

text-overflow: -o-ellipsis-lastline;

overflow: hidden;

text-overflow: ellipsis;

display: -webkit-box;

-webkit-line-clamp: 2;

line-clamp: 2;

-webkit-box-orient: vertical;

}

</style>

猜你喜欢

转载自blog.csdn.net/qq_33769914/article/details/129466778