Commit 57e90078 authored by luckyCao's avatar luckyCao Committed by Zhi Cun

Select: Fix tag show value or empty issue (17199) (#17396)

* Select: Fix tag show value or empty issue

* update docs
parent 068b3ad1
...@@ -453,7 +453,7 @@ Enter keywords and search data from server. ...@@ -453,7 +453,7 @@ Enter keywords and search data from server.
}, },
mounted() { mounted() {
this.list = this.states.map(item => { this.list = this.states.map(item => {
return { value: item, label: item }; return { value: `value:${item}`, label: `label:${item}` };
}); });
}, },
methods: { methods: {
......
...@@ -457,7 +457,7 @@ Introduzca palabras y datos para buscar desde el servidor. ...@@ -457,7 +457,7 @@ Introduzca palabras y datos para buscar desde el servidor.
}, },
mounted() { mounted() {
this.list = this.states.map(item => { this.list = this.states.map(item => {
return { value: item, label: item }; return { value: `value:${item}`, label: `label:${item}` };
}); });
}, },
methods: { methods: {
......
...@@ -453,7 +453,7 @@ Vous pouvez aller chercher les options sur le serveur de manière dynamique. ...@@ -453,7 +453,7 @@ Vous pouvez aller chercher les options sur le serveur de manière dynamique.
}, },
mounted() { mounted() {
this.list = this.states.map(item => { this.list = this.states.map(item => {
return { value: item, label: item }; return { value: `value:${item}`, label: `label:${item}` };
}); });
}, },
methods: { methods: {
......
...@@ -448,7 +448,7 @@ ...@@ -448,7 +448,7 @@
}, },
mounted() { mounted() {
this.list = this.states.map(item => { this.list = this.states.map(item => {
return { value: item, label: item }; return { value: `value:${item}`, label: `label:${item}` };
}); });
}, },
methods: { methods: {
......
...@@ -153,8 +153,13 @@ ...@@ -153,8 +153,13 @@
}, },
beforeDestroy() { beforeDestroy() {
const { selected, multiple } = this.select;
let selectedOptions = multiple ? selected : [selected];
let index = this.select.cachedOptions.indexOf(this); let index = this.select.cachedOptions.indexOf(this);
if (index > -1) { let selectedIndex = selectedOptions.indexOf(this);
// if option is not selected, remove it from cache
if (index > -1 && selectedIndex < 0) {
this.select.cachedOptions.splice(index, 1); this.select.cachedOptions.splice(index, 1);
} }
this.select.onOptionDestroy(this.select.options.indexOf(this)); this.select.onOptionDestroy(this.select.options.indexOf(this));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment