【发布时间】:2021-12-18 06:22:06
【问题描述】:
我对 Vuejs 很陌生,我想知道如何在 Vuejs 中完成这项工作
我有一组不同的数据:
data() {
return {
recents: false,
frontend: false,
backend: false,
devops: false,
tutoriais: false,
};
},
当我点击一个按钮时,它会调用 openOptions() 并将特定属性更改为 true 或 false。
openOptions(e) {
const optionClicked = e.target.text.toLowerCase();
this[optionClicked] = !this[optionClicked];
},
但是,我不能让 2 个属性为真。我需要将其他所有内容都设置为false,但我很难理解如何完成这项工作。所以基本上我需要的是
set the one I clicked to true
and the rest to false
谁能帮我解决这个问题?
【问题讨论】:
-
如果我们点击两次
recents按钮会怎样?
标签: javascript vue.js frontend