ant-design-vue-pro icon indicating copy to clipboard operation
ant-design-vue-pro copied to clipboard

this.$dialog组件如何通过事件关闭显示?

Open elicip opened this issue 3 years ago • 5 comments

Question (问题描述) 我用了this.$dialog组件去显示一个组件,用footer: ''去掉了modal的底部显示,我如何在组件里通过事件去关闭this.$dialog打开的modal呢?

Describe the solution you'd like (你期待的是什么?) 如何在组件里通过事件去关闭this.$dialog打开的modal呢?

感谢!

elicip avatar Jun 01 '21 06:06 elicip

visible 属性不是在外部受控的吗?直接改变值 false 就关了把

sendya avatar Jun 01 '21 06:06 sendya

@sendya 不是很明白你的意思

this.$dialog(TestForm,
      {
        record: {
        },
        on: {
          success() {
            _this.$message.success('成功!')
          },
        }
      },
      {
        title: 'xxx',
        width: 700,
        centered: true,
        footer: '',
        maskClosable: false
      })

应该怎么在TestForm组件里控制visible?不过我最终是用的this.$root..handleClose()去关掉了modal

elicip avatar Jun 01 '21 08:06 elicip

这样也行

有自定义需求建议自行封装

sendya avatar Jun 01 '21 09:06 sendya

@sendya 你刚才说的visiable方式怎么控制,可否指点一下,我对vue有些概念还不是很熟悉,谢谢

elicip avatar Jun 01 '21 09:06 elicip

你可以在this.$dialog方法中返回 dialogInstance 实例 通过调用 $destroy 方法销毁组件

Alfred-Skyblue avatar Oct 13 '22 08:10 Alfred-Skyblue