the reason is, the value of the selectedSize
is not changing, only the options.
i will suggest to use computed for the label so you can omit @change
event
data(){
return {
selectedSize: 'M',
sizeLabels = {
'S': 'small',
'M': 'medium',
'L': 'large'
},
selectedOptions: [] // better initialized this with array
}
},
computed:{
label(){
return this.selectedOptions.length ?
this.selectedOptions[this.selectedSize] // please handle also if key can not be found
: ''
}
}
better yet to get label also for each options
window.setTimeout(() => {
// Dynamically create values for dropdown
this.sizeOptions = [{label: 'foo', 'value': 'bar'}, etc];
}, 500);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…