Handle Bootstrap modal hide event in Vue JS

后端 未结 5 996
再見小時候
再見小時候 2020-12-16 12:49

Is there a decent way in Vue (2) to handle a Bootstrap (3) modal hide-event?

I found this as a JQuery way but I can\'t figure out how to capture this event in Vue:

5条回答
  •  春和景丽
    2020-12-16 13:35

    One option is to tie it to a variable:

    data: function(){
      return {
           showModal: false
            //starts as false.  Set as true when modal opens. Set as false on close, which triggers the watch function.
    },
    watch: {
      showModal: function(){
        if(this.showModal == false){
         // do something
      },
    }
    

    HTML

    
    
     //later if using a component
    
    
     // or alternatively in the bootstrap structure
    
    

提交回复
热议问题