In router components, can "onclick" access methods.xxx(), not using @click shorthand

<template>
    <button @click="test">a<button>
    <button onclick=" any way to call  test()  here?  ">b</button
</template>

<script>
return{
 methods:{
   test(){}
 }
}
</script>

Hi, in router components, can “onclick” access methods.xxx(), without using @click shorthand?

Thanks.

If you give your page element a name:

<div class="page" data-name="pages.mypage">

You can access your component methods like this:

$$('[data-name="pages.mypage"]')[0].f7Component.myMethod()

2 Likes

thank you , what a hack!

I’m coming back for my question. :slight_smile:

I am using virtual list’s itemTemplate and need to find a way to make @click works, like many of user on this forum.

Finally this saved my life: @click is not working in lists with virtual listview

I am sharing the code that works for me.

let virtualList = app.virtualList.create({
el: this.$el.find('.virtual-list'),
  ...,
});

this.$el.find('.virtual-list').on('click', '.buttonX', (e)=>{
   this.test( e );
});