Home > Back-end >  How to call method from div in vue
How to call method from div in vue

Time:03-16

I have a div and I just want to render it on a condition, I also want to call the method if the condition comes true here is my code

 <div v-if="timetable === null" "mymethodhere">
      <h4>no data found</h4>
 </div>

CodePudding user response:

Try a watcher on timetable and if timetable === null do things.

  watch: {
    "timetable": function (newVal) {
       if (newVal === null) {
         ---> do things
       }
     }
   }

CodePudding user response:

Maybe you can use a watcher on timetable

watch: {
    timetable(timetable){
        if (timetable === null){
            // ...
        } else {
            // ...
        }
    }
},

Official docs: https://vuejs.org/guide/essentials/watchers.html

  • Related