Marin
Marin

Reputation: 11

How to call a custom native JS function within a Vuejs 2 onclick event handler ?

I am trying to call custom JS functions within onclick event with Vuejs 2 and I get the below error. I omitted the curly braces for the prop used as per the migration guide.

Any ideas ?

Thanks.

Upvotes: 1

Views: 1728

Answers (2)

Mohsen
Mohsen

Reputation: 4235

I usually rethink about putting native code in or Out of VueJs, sometimes using onclick is easier than on:click, if need call such these native functions in VueJs can call them by:

window.funcName()

Upvotes: 1

Evgeny Melnikov
Evgeny Melnikov

Reputation: 1092

I think you should try to move your native function call to VueJS event handler (in methods). In other words, just wrap.

Upvotes: 1

Related Questions