Przeglądaj źródła

修复cl-text设置超大号字体时导致的多行重叠和web端显示不全的问题

richfugui001-netizen 4 miesięcy temu
rodzic
commit
c6591fca63
1 zmienionych plików z 11 dodań i 3 usunięć
  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;