Answer the question
In order to leave comments, you need to log in
How to pass attribute to vue method?
There is a script
var pathArray = location.href.split( '/' );
var protocol = pathArray[0];
var host = pathArray[2];
var url = protocol + '//' + host;
var itemlist = new Vue({
el: '#itemlist',
data: {
json: null
},
methods: {
getVariant: function (event) {
var good = this.getAttribute('data-id');
$.getJSON(url + good, function (json) {
itemlist.json = json;
console.log(itemlist.json);
});
}
}
});
<li class="color-variant__choose color-variant__choose_<?=$value?>"
data-id="12345" //к примеру, но вообще она может быть любой
v-on:click="getVariant"
>
</li>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question