Element 对话框 el-dialog 强制渲染

element为了优化性能,在弹框未首次打开之前,是会不渲染弹框body中的内容的,一般情况下这样的设定是没有问题的,弹框未打开时我们一般也是不需要对弹框内容做操作的,但是在一些特殊情况,可能就有问题了

解决办法:

    <el-dialog
      title="设计配置项"
      :visible.sync="designDialogVisible"
      width="1600px"
      ref="designDialog"
    >
      <div>
        1
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="designDialogVisible = false"
          >取 消</el-button
        >
        <el-button
          type="primary"
          size="small"
          @click="handleDesignDialogSubmit()"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  mounted() {
    this.$refs.designDialog.rendered = true
  }

antd 的 Model组件可以通过forceRender属性解决这个问题

https://ant.design/components/modal-cn/

猜你喜欢

转载自blog.csdn.net/xutongbao/article/details/122999662