【发布时间】:2019-06-22 09:16:44
【问题描述】:
我正在使用Vue.js modal 包,但我不知道如何从我的模式窗口中获取响应数据。我为我的模态窗口创建了一个组件。组件用法如下所示:
<MyModal :data="data"
@closed="modalClosed"/>
我想从关闭的事件中获取数据。我打开我的模式:
this.$modal.show('my-modal')
然后关闭它:
<button type="button" @click="$modal.hide('my-modal', {success: true})" class="delete mr-3" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
我的模态在 MyModal 组件中定义(我省略了 html 和脚本代码):
<template>
<modal
name="my-modal"
transition="nice-modal-fade"
:delay="100"
:width="'100%'"
:height="'auto'"
:classes="['v--modal', 'col-xl-6', 'col-lg-6', 'col-md-8', 'col-sm-12', 'col-xs-12', 'offset-md-2', 'offset-lg-3', 'offset-xl-3']"
:scrollable="true"
:adaptive="true"
:maxHeight="100">
</modal>
</template>
@closed 钩子在模态框内有效,但在我需要的地方无效。我对 Vue.js 没有任何经验,这是我第一次尝试模态窗口,所以我真的不知道我在这里缺少什么,而且文档真的很糟糕。
【问题讨论】:
标签: vue.js modal-dialog vue-component