diff --git a/pages/demo/basic/text.uvue b/pages/demo/basic/text.uvue index 1e3c18e..490a91c 100644 --- a/pages/demo/basic/text.uvue +++ b/pages/demo/basic/text.uvue @@ -19,6 +19,22 @@ > + + 云想衣裳花想容,春风拂槛露华浓。若非群玉山头见,会向瑶台月下逢。 + + + + 云想衣裳花想容,春风拂槛露华浓。若非群玉山头见,会向瑶台月下逢。天阶夜色凉如水,卧看牵牛织女星。人生若只如初见,何事秋风悲画扇。山有木兮木有枝,心悦君兮君不知。 + + + + + + @@ -35,19 +51,9 @@ - - - - - - - 云想衣裳花想容,春风拂槛露华浓。若非群玉山头见,会向瑶台月下逢。 - diff --git a/uni_modules/cool-ui/components/cl-text/cl-text.uvue b/uni_modules/cool-ui/components/cl-text/cl-text.uvue index 126ff9e..ded0a96 100644 --- a/uni_modules/cool-ui/components/cl-text/cl-text.uvue +++ b/uni_modules/cool-ui/components/cl-text/cl-text.uvue @@ -114,6 +114,11 @@ const props = defineProps({ type: Boolean, default: false }, + // 最大行数 + lines: { + type: Number, + default: 1 + }, // 是否可选择 selectable: { type: Boolean, @@ -185,7 +190,9 @@ const isDefaultSize = computed(() => !hasTextSize(pt.value.className ?? "")); // 文本样式 const textStyle = computed(() => { - const style = {}; + const style = { + lines: props.lines + }; // 判断是不是有颜色样式 if (!hasTextColor(ptClassName.value)) { @@ -320,7 +327,16 @@ const content = computed(() => { } &--ellipsis { - @apply truncate w-full; + text-overflow: ellipsis; + + // #ifndef APP + display: -webkit-box; + overflow: hidden; + text-overflow: ellipsis; + -webkit-line-clamp: v-bind(lines); + line-break: anywhere; + -webkit-box-orient: vertical; + // #endif } &--default-size {