Can Vue allow for the addition of v-on
events on strings included in v-html
? In this scenario, clicking the 'Maggie' link doesn't produce any action. It appears that it's not recognized by Vue.
Is there an alternative method to achieve this? I am currently using Vue.js version 2.1.3
Javascript
window.onload = function() {
new Vue({
el: '#app',
data: {
users: ['Homer', 'Marge', 'Bart', 'Lisa', '<a href="#" v-on:click="click_user">Maggie</a>']
},
methods: {
click_user: function() {
console.log('Click user')
},
}
})
}
HTML
<div id="app">
<div v-for="user in users" v-html="user"></div><br>
<a href="#" v-on:click="click_user">This works.</a>
</div>