【问题标题】:vue-js-modal dialog does not closevue-js-modal 对话框没有关闭
【发布时间】:2018-10-10 21:06:02
【问题描述】:

我不知道这是否只是文档中缺少某些内容的问题,还是我误解了 vue-js-modal 包的工作原理。 我似乎无法关闭对话框模式

示例和截图:

我已经创建了这个模态对话框:

delete_entry_modal(item) {
    this.$modal.show('dialog', {
        title: 'Delete entry?',
        text: `Are you sure that you want to delete the ${item.listing_type} entry from ${item.from_address} to ${item.to_address }@${item.to_domain}?`,
        buttons: [
            {
                title: 'Yes',
                handler: () => {
                    this.setLoading(true);
                    axios.delete('/api/lists/'+item.id+'/').then(response => {
                        this.setLoading(false);
                        this.notify(this.createNotification('Entry deleted', `The ${item.listing_type} entry from ${item.from_address} to ${item.to_address }@${item.to_domain} has been deleted`, 'success'));
                    }).catch(error => {
                        this.setLoading(false);
                        this.notify(this.createNotification('An error occurred', `${error}`, 'error'));
                    });
                    this.$emit('close');
                },
                default: true
            },
            {
                title: 'No'
            }
        ]
    })
}

我以这种方式加载 VModal:

Vue.use(VModal, { dialog: true, dynamic: true, injectModalsContainer: true });

当我单击“否”按钮时,模式关闭。如果我单击“是”,它会运行处理程序代码,但不会关闭模式。在键盘上按Enter 会产生相同的结果

【问题讨论】:

  • 你有错误吗?

标签: javascript vue.js vuejs2 modal-dialog


【解决方案1】:

$emit 通过向父级广播在模板范围内工作。因为您没有使用模板,所以您需要通过附加到 VueConstructor 来明确定义要在语法中关闭的模式

this.$modal.hide('dialog')

【讨论】:

    猜你喜欢
    • 2018-01-04
    • 1970-01-01
    • 1970-01-01
    • 2011-12-14
    • 1970-01-01
    • 1970-01-01
    • 2013-12-17
    • 1970-01-01
    • 2022-01-05
    相关资源
    最近更新 更多