Reputation: 3523
in an Express app, I need to pass an object to vue method, here is the ejs template:
<%-item.price%>
<button v-on:click="add_to(<%=item%>)" class="float-right">Add...</button>
here is the js:
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
},
methods: {
add_to: function (item) {
console.log(item)
}
}
})
but it does not work, any hint? Thanks
Upvotes: 3
Views: 1315
Reputation: 11
You need to enclose the ejs rendering the object you want to pass to the vue.js method with single quote ''
v-on:click="add_to('<%=item%>')"
Upvotes: 1