如何使用离子模态控制器捕获模态 this.$emit [英] How can i catch a modal this.$emit using ionic modal controller

查看:23
本文介绍了如何使用离子模态控制器捕获模态 this.$emit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在将我的一些网络代码转换为 ionic-vue 应用程序,我想知道我们是否可以使用经典 vuecomponent 的 ionic 模态控制器从我的模态中捕获 this.$emit.

Hello i'm converting somme of my web code to an ionic-vue app and i wanted to know if we can catch a this.$emit from my modal using the ionic modal controller insted of classic vuecomponent.

基本上我想翻译

<NewAppointmentModal @onSuccess="handleAppointmentCreation"/>

this.$ionic.modalController.create({ component: NewAppointmentModal}).then(m => m.present())
//how can i catch the onSuccess event like before 

推荐答案

ParentComponent.vue

ParentComponent.vue

public openModal() {
    return this.$ionic.modalController
    .create({
      component: ModalComponent,
      componentProps: {
        data: {
          content: 'New Content',
        },
        propsData: {
          //user_id: user_id
        },
        parent: this,
      },
    })
    .then(m => m.present({

    }))
}

public mounted() {
   this.$on('close', (foo) => {
       this.$ionic.modalController.dismiss()
   })
}

ModalComponent.vue

ModalComponent.vue

<template>
   <ion-button @click="dismissModal()">Close</ion-button>
</template>
<script>
   dismissModal() {
     this.$parent.$emit('close', { foo: 'bar' })
   }
</script>

这篇关于如何使用离子模态控制器捕获模态 this.$emit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆