bug fix:showSelectList options的closeOnSelect设置为false时,选项只能点一次

修改:添加每个选项独立的事件注册
This commit is contained in:
wanmeihuaxu
2025-01-16 16:02:55 +08:00
parent fcc8f47127
commit 0664e021d0
3 changed files with 13 additions and 3 deletions

View File

@@ -186,6 +186,9 @@ export default {
* initItems = [{title: "1", description: "1"}, {title: "2", description: "2"}, {title: "3", description: "3"}]
* options = {placeholder: "输入进行筛选,支持拼音", optionType: "json", enableSearch: true, showCancelButton: false, closeOnSelect: true}
*
* 如需对每个选项单独注册点击事件可以在initItems的元素中添加id和clickFn
* initItems = [{id:1, title: "1", description: "1", clickFn:function(e){console.log(e)}}, {id:2, title: "2", description: "2", clickFn:function(e){console.log(e)}}]
*
* @example
* initItems = ["<div>1</div>", "<div>2</div>", "<div>3</div>"]
* options = {placeholder: "输入进行筛选,支持拼音", optionType: "html", enableSearch: true, showCancelButton: false, closeOnSelect: true}

View File

@@ -144,7 +144,7 @@ export default {
id: this.currentIndex,
text: this.matchedItems[this.currentIndex],
};
this.$emit("clickOK", selected);
this.is.json && selected.clickFn ? selected.clickFn(this.matchedItems[this.currentIndex].id) : this.$emit("clickOK", selected);
this.options.options.closeOnSelect && this.hide();
},