From 126bb651687c1406accd2fc37c3f98de35da6890 Mon Sep 17 00:00:00 2001
From: icssoa <615206459@qq.com>
Date: Mon, 8 Sep 2025 15:44:52 +0800
Subject: [PATCH] =?UTF-8?q?cl-text=20=E6=94=AF=E6=8C=81=E5=A4=9A=E8=A1=8C?=
=?UTF-8?q?=E7=9C=81=E7=95=A5=E5=8F=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/demo/basic/text.uvue | 26 ++++++++++++-------
.../cool-ui/components/cl-text/cl-text.uvue | 20 ++++++++++++--
2 files changed, 34 insertions(+), 12 deletions(-)
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 {