To begin, I am looking to initialize the properties of image, description, video, and title with the corresponding fields from the first element in the variants array. The variants array is retrieved by sending an AJAX request that returns a JSON file.
var app = new Vue({
el: '#app',
data: {
name: '<?php echo $name ?>',
image: '',
description: '',
video: '',
title: '',
variants: ''
},
methods: {
updateAll: function(im, des, t, v) {
this.image = im;
this.description = des;
this.title = t;
this.video = v;
},
getQuery: function() {
axios.get('ajaxfile.php', {
params: {
name: this.name
}
}).then(function(response) {
app.variants = response.data;
}).catch(function(error) {
console.log(error);
});
}
},
created: function() {
this.getQuery()
}
});