Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复在vue3中使用h函数value指定默认值无效,只能通过modelValue #846

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions uni_modules/uni-data-select/changelog.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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: {
Expand All @@ -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) {
Expand All @@ -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) : ''
Expand Down Expand Up @@ -329,8 +329,8 @@
display: flex;
align-items: center;
// padding: 15px;
/* #ifdef H5 */
cursor: pointer;
/* #ifdef H5 */
cursor: pointer;
/* #endif */
width: 100%;
flex: 1;
Expand Down
2 changes: 1 addition & 1 deletion uni_modules/uni-data-select/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "uni-data-select",
"displayName": "uni-data-select 下拉框选择器",
"version": "1.0.7",
"version": "1.0.8",
"description": "通过数据驱动的下拉框选择器",
"keywords": [
"uni-ui",
Expand Down