# tui-overflow-hidden 内容超出隐藏 会员组件
介绍
内容超出隐藏:渐变隐藏需要设置内容区域高度。
# 引入
# uni-app引入
第一种,手动引入(可全局引入)
import tuiOverflowHidden from "@/components/thorui/tui-overflow-hidden/tui-overflow-hidden.vue"
export default {
components:{
tuiOverflowHidden
}
}
第二种,开启easycom组件模式,如果不了解如何配置,可先查看 官网文档 (opens new window)。
# uni-app版本平台差异说明
App-Nvue | App-vue | H5 | 微信小程序 | 支付宝小程序 | 百度小程序 | 字节小程序 | QQ小程序 |
---|---|---|---|---|---|---|---|
升级中 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
# 微信小程序引入(可在app.json中全局引入)
{
"usingComponents": {
"tui-overflow-hidden": "/components/thorui/tui-overflow-hidden/tui-overflow-hidden"
}
}
# 代码演示
部分功能演示,具体可参考示例程序以及文档API。
默认使用
默认显示两行。
<tui-overflow-hidden>
人的一生要想活得幸福,走得更为长远,有一项能力必不可少,那就是感恩能力。卡耐基曾说过,感恩是极有教养的产物,你不可能从一般人身上得到,因为忘记或不会感谢乃是人的天性。
</tui-overflow-hidden>
显示一行
通过 lineClamp
属性设置显示行数。
<!--uni-app-->
<tui-overflow-hidden :lineClamp="1">
人的一生要想活得幸福,走得更为长远,有一项能力必不可少,那就是感恩能力。卡耐基曾说过,感恩是极有教养的产物,你不可能从一般人身上得到,因为忘记或不会感谢乃是人的天性。
</tui-overflow-hidden>
<!--微信小程序-->
<tui-overflow-hidden lineClamp="{{1}}">
人的一生要想活得幸福,走得更为长远,有一项能力必不可少,那就是感恩能力。卡耐基曾说过,感恩是极有教养的产物,你不可能从一般人身上得到,因为忘记或不会感谢乃是人的天性。
</tui-overflow-hidden>
渐变隐藏
通过 type
属性设置隐藏类型(1-文本超出设定行数隐藏,2-渐变隐藏),通过 height
属性设置内容区域高度(type=2时生效且需要传入具体值,高度值要低于实际内容高度)。
<!--uni-app-->
<tui-overflow-hidden :type="2" height="300rpx" padding="30rpx 30rpx 0 30rpx" gradientColor="#f8f8f8"
:removeGradient="removeGradient">
<rich-text :nodes="richText"></rich-text>
</tui-overflow-hidden>
<!--微信小程序-->
<tui-overflow-hidden type="{{2}}" height="300rpx" padding="30rpx 30rpx 0 30rpx" gradientColor="#f8f8f8"
removeGradient="{{removeGradient}}">
<rich-text nodes="{{richText}}"></rich-text>
</tui-overflow-hidden>
# Slots
插槽名称 | 说明 |
---|---|
default | 需要展示的内容 |
# Props
属性名 | 类型 | 说明 | 默认值 |
---|---|---|---|
width | String | 内容区域宽度 | 100% |
height | String | 内容区域高度,type=2时生效且需要传入具体值,高度值要低于实际内容高度 | auto |
padding | String | 内容外层padding值,type=2时生效 | 0 |
backgroundColor | String | 内容区域背景色 | transparent |
size | [Number, String] | 文本字体大小,单位rpx | 32 |
color | String | 文本字体颜色 | #333 |
bold | Boolean | 文本内容是否加粗 | false |
type | [Number, String] | 隐藏类型:1-文本超出设定行数隐藏,2-渐变隐藏 | 1 |
lineClamp | [Number, String] | 超出多少行开始隐藏,type=1时生效 | 2 |
textOverflow | String | clip、ellipsis、string,参考CSS text-overflow 属性 | ellipsis |
gradientColor | String | 渐变隐藏遮罩背景色,与页面或内容区域背景色保持一致 | #fff |
removeGradient | Boolean | 移除渐变隐藏,显示全部内容,type=2时生效 | false |
index | Number | 列表中的索引值 | 0 |
# Events
注:uni-app端绑定事件使用@前缀,如@click;微信小程序原生使用bind前缀,如bindclick
事件名 | 说明 | 回调参数 |
---|---|---|
click | 点击内容区时触发 | {index: Number} |
# 预览
请以移动端效果为准,touch事件目前尚未在PC端做兼容。
# 特别说明
该组件为 会员组件
,非开源内容,需开通会员才可获取使用。
# 线上程序扫码预览
![]() | ![]() | ![]() |
---|---|---|
ThorUI组件库小程序码 | H5二维码 | ThorUI示例小程序码 |