我有这些 combobox 芯片,但有一个问题 deletable-chips
<v-combobox
v-model="selectedCategories"
:items="attributeCategories"
item-text="name"
item-value="id"
label="Category"
multiple
chips
clear-icon="mdi-close-circle"
deletable-chips
v-on:change="changeCategory(selectedCategories)"
></v-combobox>
有没有办法防止特定芯片被删除?例如,不在特定的按钮上显示删除按钮?假设对于 Device 且只允许删除 Weather 和 Geo Location
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
而不是使用
v-chips内置的删除方法。您可以通过自定义@click:close事件来实现。我为您创建了一个工作演示:new Vue({ el: '#app', vuetify: new Vuetify(), data: () => ({ model: [], items: [ { text: 'Weather' }, { text: 'Geo Location' }, { text: 'Device' } ] }), methods: { remove (itemText) { if (itemText === 'Device') { return; } else { this.model.forEach(obj => { if (obj.text === itemText) { this.model.splice(this.model.indexOf(obj), 1) } }) this.model = [...this.model] } } } })