Browse Source

Merge pull request #60 from richfugui001-netizen/patch-1

修复cl-text设置超大号字体时导致的多行重叠和web端显示不全的问题
COOL 4 months ago
parent
commit
cb6f20cbd6
1 changed files with 11 additions and 3 deletions
  1. 11 3
      uni_modules/cool-ui/components/cl-text/cl-text.uvue

+ 11 - 3
uni_modules/cool-ui/components/cl-text/cl-text.uvue

@@ -209,9 +209,17 @@ const textStyle = computed(() => {
 	}
 
 	// 行高
-	const lineHeight = getLineHeight();
-	if (lineHeight != null) {
-		style["lineHeight"] = lineHeight;
+	// 判断是否多行文本
+	const isMultiLine = props.preWrap || !props.ellipsis || props.lines > 1;
+	if (isMultiLine) {
+		// 多行文本,行高交给浏览器/平台自动计算
+		style["lineHeight"] = "normal";
+	} else {
+		// 单行文本,使用原来的行高逻辑
+		const lineHeight = getLineHeight();
+		if (lineHeight != null) {
+			style["lineHeight"] = lineHeight;
+		}
 	}
 
 	return style;