【问题标题】:Vue-material Dialog : Close DialogVue-material 对话框:关闭对话框
【发布时间】:2018-01-04 04:03:57
【问题描述】:

我正在使用 vue-material Dialog 来显示一个表单,我已经这样做了:

LeftSidenav.vue - 模板:

<md-button class="list-button" id="formBtn" @click="openFormDialog()">
      <md-icon>description</md-icon>
      <span class="sidenav-item-text">{{$t('form_dialog')}}</span>
      <md-tooltip md-delay="100" md-direction="right">{{$t('form_dialog'')}}</md-tooltip>
    </md-button>
    <md-dialog md-open-from="#formBtn" ref="formDialog">
      <md-dialog-title>Title</md-dialog-title>

      <md-dialog-content>
        <form-dialog></form-dialog>
      </md-dialog-content>
</md-dialog>

LeftSidenav.vue - 脚本:

methods: {
  openFormDialog() {
    this.$refs.formDialog.open();
  },
  closeFormDialog() {
    this.$refs.formDialog.close();
  },
},

FormDialog.vue:

<template>
  <div>
    Test
    <div class="buttons">
      <md-button class="md-raised" @click="closeFormDialog">Cancel</md-button>
      <md-button class="md-raised">Submit</md-button>
    </div>
  </div>
</template>

问题出在我的 FormDialog 我不知道如何访问 closeFormDialog 方法,如何通过单击 FormDialog.vue 上的取消按钮来关闭我的对话框?

【问题讨论】:

  • 您找到解决方案了吗?我有完全相同的问题
  • 嗨,悉达多!不,我没有找到解决方案我仍然有这个问题:/
  • 我现在没有这个问题,因为我更换了 vue :D
  • 哈哈哈!我喜欢 vue,但我仍然无法执行关闭操作,在 vuejs 论坛中有人告诉我使用 $emit 但这不起作用:/

标签: vuejs2 vue-material


【解决方案1】:
<el-dialog
  :visible="dialogVisible"
  title="Contact Form View"
  ref="changeUserId"
  :before-close="() => dialogVisible = false"
>
  <contact-form />
</el-dialog>

检查它是否与关闭前的元素ui功能相同

【讨论】:

    猜你喜欢
    • 2017-04-05
    • 2020-06-02
    • 1970-01-01
    • 1970-01-01
    • 2017-06-04
    • 1970-01-01
    • 1970-01-01
    • 2022-01-05
    • 1970-01-01
    相关资源
    最近更新 更多