14 el-dialog 基本结构

1 dialogVisible父组件提供,:visible.sync直接修改父组件的dialogVisible,会报错,需要加上before-close属性 

<template>

  <el-dialog title="提示" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
    <span>这是一段信息</span>
    <span slot="footer" class="dialog-footer">
      <el-button @click="handleCancel">取 消</el-button>
      <el-button type="primary" @click="handle">确 定</el-button>
    </span>
  </el-dialog>
</template>
<script>
export default {
  name: "InfoIndexDialog",
  props: {
    dialogVisible: {
      type: Boolean,
      required: true
    }
  },
  data() {
    return {};
  },
  methods: {
    changePropsDialogVisible() {
      this.$emit("update:dialogVisible", false);
    },
    handleClose() {
      this.changePropsDialogVisible();
    },
    handleCancel() {
      this.changePropsDialogVisible();
    },
    handle() {
      this.changePropsDialogVisible();
    }
  }
};
</script>
<style lang="scss" scoped>
</style>

 2.重置表单

this.$refs['formname'].resetFields();生效方法前提是必须给每个form-item加上prop
原文地址:https://www.cnblogs.com/xiaoliziaaa/p/13129668.html