移动端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

59 lines
1.1 KiB

<template>
<view :style="{ color: color }">
<view
style="
font-size: 28rpx;
line-height: 160%;
position: relative;
color: inherit;
white-space: normal;
"
v-if="value.length < splitLength"
>
{{ value }}
</view>
<view
v-else
style="
font-size: 28rpx;
line-height: 160%;
position: relative;
color: inherit;
white-space: normal;
"
@tap.native.stop="isShowAllText = !isShowAllText"
>
{{ isShowAllText ? value : `${value.slice(0, splitLength)}...` }}
<text style="color: #17c653; padding-left: 8rpx">
{{ isShowAllText ? '收起' : '展开' }}
</text>
</view>
</view>
</template>
<script>
export default {
name: 'cs-text-more',
data() {
return {
isShowAllText: false
}
},
props: {
value: {
type: String,
default: '文本简介'.repeat(20)
},
color: {
type: String,
default: '#4b5675'
},
splitLength: {
type: Number,
default: 62
}
}
}
</script>
<style lang="scss"></style>