Skip to content

Commit 60f2fe6

Browse files
authored
fix: 🐛 修复 Textarea 设置为 null 时,显示字数限制显示错误问题 (#1004)
Closes: #1003
1 parent a200337 commit 60f2fe6

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/uni_modules/wot-design-uni/components/wd-textarea/wd-textarea.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ const currentLength = computed(() => {
181181
* 使用Array.from处理多码元字符以获取正确的长度
182182
* @link https://github.com/Moonofweisheng/wot-design-uni/issues/933
183183
*/
184-
return Array.from(String(formatValue(props.modelValue) || '')).length
184+
return Array.from(String(formatValue(props.modelValue))).length
185185
})
186186
187187
const rootClass = computed(() => {
@@ -224,6 +224,7 @@ function initState() {
224224
}
225225
226226
function formatValue(value: string | number) {
227+
if (value === null || value === undefined) return ''
227228
const { maxlength, showWordLimit } = props
228229
if (showWordLimit && maxlength !== -1 && String(value).length > maxlength) {
229230
return value.toString().substring(0, maxlength)

0 commit comments

Comments
 (0)