下面是一个示例代码。但问题是,一旦你禁用了这个按钮,你就不能点击它了。也许添加一个复选框来启用所有按钮?
<div id="app">
<v-app id="inspire">
<div v-for="button in buttons">
<button @click="updateMenu(button.name)" :disabled='button.isDisabled'>{{ button.name }}</button>
</div>
</v-app>
</div>
new Vue({
el: '#app',
vuetify: new Vuetify(),
data: () => ({
buttons: [{name: "menu one", isDisabled: false}, {name: "menu two", isDisabled: false}, {name: "menu three", isDisabled: false}, {name: "menu four", isDisabled: false}]
}),
methods: {
updateMenu: function (name) {
const button = this.buttons.find(b => b.name === name);
button.isDisabled = false;
const toDisableButtons = this.buttons.filter(b => b.name != name);
toDisableButtons.forEach(function(item) {
item.isDisabled = true;
});
}
}
});