Could someone please explain to me how to swap two different sets of data when clicked?
For instance, let's say we have the following data:
data() {
return {
data_one: [
{
name: "Simo",
age: "32"
}
],
data_two: [
{
name: "Lisa",
age: "25"
}
],
}
},
I would like to display this data using v-for
, and have two buttons that allow switching between data_one and data_two, with data_one displayed by default.
<button @click="change_to_data_one">Data 1<button>
<button @click="change_to_data_two">Data 2<button>
<li v-for="item in data_one">{{item.name}} - {{item.age}}<li>