diff --git a/uni_modules/uni-data-select/changelog.md b/uni_modules/uni-data-select/changelog.md index 639b4596..bb5390ef 100644 --- a/uni_modules/uni-data-select/changelog.md +++ b/uni_modules/uni-data-select/changelog.md @@ -1,3 +1,5 @@ +## 1.0.8(2024-02-20) +- 修复 在vue3中使用h函数value指定默认值无效,只能通过modelValue ## 1.0.7(2024-01-20) - 修复 长文本回显超过容器的bug,超过容器部分显示省略号 ## 1.0.6(2023-04-12) diff --git a/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue b/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue index f2f779b3..2b2728ff 100644 --- a/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue +++ b/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue @@ -125,23 +125,15 @@ common + placeholder : common }, - valueCom(){ - // #ifdef VUE3 - return this.modelValue; - // #endif - // #ifndef VUE3 - return this.value; - // #endif - }, - textShow(){ - // 长文本显示 - let text = this.current; - if (text.length > 10) { - return text.slice(0, 25) + '...'; - } - return text; + textShow(){ + // 长文本显示 + let text = this.current; + if (text.length > 10) { + return text.slice(0, 25) + '...'; + } + return text; } - }, + }, watch: { localdata: { @@ -152,17 +144,25 @@ } } }, - valueCom(val, old) { - this.initDefVal() + value (val) { + this.initDefVal(val) + }, + modelValue (val) { + this.initDefVal(val) }, mixinDatacomResData: { immediate: true, handler(val) { if (val.length) { - this.initDefVal() + // #ifdef VUE3 + this.initDefVal(this.modelValue !== undefined ? this.modelValue : this.value) + // #endif + // #ifndef VUE3 + this.initDefVal(this.value) + // #endif } } - }, + }, }, methods: { @@ -185,10 +185,10 @@ this.debounceGet(); } }, - initDefVal() { + initDefVal(val) { let defValue = '' - if ((this.valueCom || this.valueCom === 0) && !this.isDisabled(this.valueCom)) { - defValue = this.valueCom + if ((val || val === 0) && !this.isDisabled(val)) { + defValue = val } else { let strogeValue if (this.collection) { @@ -203,9 +203,9 @@ } defValue = defItem } - if (defValue || defValue === 0) { - this.emit(defValue) - } + if (defValue || defValue === 0) { + this.emit(defValue) + } } const def = this.mixinDatacomResData.find(item => item.value === defValue) this.current = def ? this.formatItemName(def) : '' @@ -329,8 +329,8 @@ display: flex; align-items: center; // padding: 15px; - /* #ifdef H5 */ - cursor: pointer; + /* #ifdef H5 */ + cursor: pointer; /* #endif */ width: 100%; flex: 1; diff --git a/uni_modules/uni-data-select/package.json b/uni_modules/uni-data-select/package.json index 1af59240..f617f9be 100644 --- a/uni_modules/uni-data-select/package.json +++ b/uni_modules/uni-data-select/package.json @@ -1,7 +1,7 @@ { "id": "uni-data-select", "displayName": "uni-data-select 下拉框选择器", - "version": "1.0.7", + "version": "1.0.8", "description": "通过数据驱动的下拉框选择器", "keywords": [ "uni-ui",