[Vuejs]-Vue: passing onclick-method name via props

4👍

How about using a helper method ..

methods: {
  ...
  call(methodName) {
    this[methodName]()
  }
}

Then you can do this in your template ..

 <v-btn icon flat class="header-button" v-for="(button, i) in cardHeaderButtons"
                       :key="i"
                       v-if="$vuetify.breakpoint.lgAndUp"
                       color="white"
                       @click.capture.stop="call(button.fn)"
>

1👍

maybe try @click.capture.stop="eval(button.fn).call()"

https://www.w3schools.com/js/js_function_call.asp

1👍

pass button as parameter to a method like :

   @click.capture.stop="callBtn(button)"

in your methods :

  methods:{
      callBtn(button){
       button.fn();
       }
    ...  
     }

Leave a comment