Open a Vuetify dialog from a component template in VueJS

前端 未结 8 1375
故里飘歌
故里飘歌 2020-12-02 11:27

I\'m using the VueJS Vuetify framework and I need to open a dialog - that gets imported as a component template - from another template. Once the Menu butto

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 12:05

    The most simpler way I found to do it is:

    in data() of component, return a attribute, let's say, dialog.

    When you include a component, you can set a reference to your component tag. E.g.:

    import Edit from '../payment/edit.vue';
    
    
    

    Then, inside my component, I have set a method:

            open: function () {
                var vm = this;
    
                vm.dialog = true;
            }
    

    Finally, I can call it from parent, using:

      editar(item)
      {
          var vm = this;
    
          vm.$refs.edit_reference.open();
      }
    

提交回复
热议问题