0👍
✅
Here is the documentation about methods :
Example :
<template>
<p>{{ myDatabase[0].isPreview }}</p>
<button @click="reversePreview(1)">Reverse preview</button>
</template>
<script>
export default {
data () {
return {
myDatabase: [{
id: 1,
name: "Blue",
fabric: require("../static/images/blue.jpeg"),
previewImage: require("../static/images/blue-shirt.jpeg"),
isPreview: true
},
{
id: 2,
name: "Black",
fabric: require("../static/images/black.jpeg"),
previewImage: require("../static/images/black-shirt.jpeg"),
isPreview: false
}]
}
},
methods: {
reversePreview (id) {
const index = this.myDatabase.findIndex(db => db.id === id)
this.myDatabase[index].isPreview = !this.myDatabase[index].isPreview
}
}
}
</script>
Source:stackexchange.com