Open Dacheng-Zhao-activehealth opened 7 years ago
// Assuming you have a data structure to store selected options
data() {
return {
selectedOptions: [],
unselectedOptions: [],
customInput: '', // Input for adding custom values
};
},
methods: {
// Function to handle adding custom values to selected options
addCustomValue() {
if (this.customInput.trim() !== '') {
this.selectedOptions.push(this.customInput.trim());
this.customInput = ''; // Clear the input field
}
},
// Function to handle removing selected options
removeSelectedOption(index) {
this.selectedOptions.splice(index, 1);
},
// Function to handle keypress event (Enter key)
handleKeyPress(event) {
if (event.key === 'Enter') {
this.addCustomValue();
}
},
},
Please add selectedoptions and unselectedoptions to scope so it will be easy to add data from input to selected. Thank you