dynamically swapping a method of a button in vuejs based off of data

I have a vuejs sample where I am trying to dynamically change the button based on the data found in the vue model? So for instance, if the data says video in the returned data, I want the method to trigger and alert. If the data says another, I want it to display another message.

new Vue({
  el: "#app",
  data: {
  methods: {
    step1: function(){
        step2: function(){
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  <button v-on:click="step1()">
  Click 1

>Solution :

Try to use an inline handler with ternary operator :

 <button v-on:click="click==='video'?step1():step2()">

Leave a Reply