Elements Events Rendered by the v-html Directive in Vue.js

Asked

Viewed 17 times

1

How do I use an event in an element rendered by the v-html directive? The Vue (@event) events do not work.. I tried calling a function by onclick, but it is not found.

 <button onclick="test()" class="botao">Adicionar ao carrinho</button> // NÃO FUNCIONA

<button onclick="console.log('Clicado')" class="botao">Adicionar ao carrinho</button>  //FUNCIONA

The above codes are being rendered by v-html as in the example below:

<div v-html="<button onclick="test()" class="botao">Adicionar ao Carrinho</button>">

</div>
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.