组件封装-基本对话框
<template> <!-- 弹窗 --> <!-- @close="closeDialog" 事件--> <el-dialog title="提示" :visible.sync="dialogVisible" width="40%" :before-close="handleClose" > <!-- 表格 可以使用布局排列 --> <!-- formData是整体表单的绑定数据 formRules是表单校验规则 label-width是表单标签的宽度 --> <el-form :model="formData" ref="formRef" :rules="formRules" label-width="80px" :inline="false" size="normal" > <el-form-item label="我是表单" prop=""> <el-input></el-input> </el-form-item> <el-form-item label="我是表单" prop=""> <el-input></el-input> </el-form-item> </el-form> <span slot="footer" class="dialog-footer"> <el-button @click="dialogVisible = false">取 消</el-button> <el-button type="primary" @click="dialogVisible = false">确 定</el-button> </span> </el-dialog> </template> <script> export default { data() { return { formData: {}, formRules: {}, dialogVisible: true, }; }, methods: { // 这个需要手动关闭弹窗 handleClose() { console.log("handleclose"); this.dialogVisible = false; }, // 这是是直接关闭弹窗 // closeDialog() { // console.log(11); // }, }, }; </script>