Skip to content

Commit

Permalink
fix(uni-data-select): select invaild when value is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Fasttian committed May 8, 2022
1 parent d931987 commit 794481a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
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 @@
## 0.1.2(2022-05-08)
- 修复 当 value 为 0 时选择不生效的 bug
## 0.1.1(2022-05-07)
- 新增 记住上次的选项(仅 collection 存在时有效)
## 0.1.0(2022-04-22)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,31 @@
}
},
methods: {
initDefVal() {
let defItem = ''
if (this.defItem > 0 && this.defItem < this.mixinDatacomResData.length) {
defItem = this.mixinDatacomResData[this.defItem - 1].value
initDefVal() {
let defValue = ''
if (this.value ||this.value === 0) {
defValue = this.value
} else if(this.modelValue || this.modelValue === 0 ) {
defValue = this.modelValue
} else {
let strogeValue
if (this.collection) {
strogeValue = uni.getStorageSync(this.last)
}
if (strogeValue || strogeValue === 0) {
defValue = strogeValue
} else {
let defItem = ''
if (this.defItem > 0 && this.defItem < this.mixinDatacomResData.length) {
defItem = this.mixinDatacomResData[this.defItem - 1].value
}
defValue = defItem
}
this.emit(defValue)
}
let strogeValue
if (this.collection) {
strogeValue = uni.getStorageSync(this.last)
}
const defValue = this.value || this.modelValue || strogeValue || defItem
const def = this.mixinDatacomResData.find(item => item.value === defValue)
this.current = def ? this.formatItemName(def) : ''
this.emit(defValue)
},
},
clearVal() {
this.emit('')
Expand Down
5 changes: 3 additions & 2 deletions 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": "0.1.1",
"version": "0.1.2",
"description": "通过数据驱动的下拉框选择器",
"keywords": [
"uni-ui",
Expand Down Expand Up @@ -71,7 +71,8 @@
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y"
"QQ": "y",
"京东": "u"
},
"快应用": {
"华为": "y",
Expand Down

0 comments on commit 794481a

Please sign in to comment.