1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| 组件封装: <template> <span> <span class="resetPass" @click="openDialog">修改密码</span> <el-dialog :visible.sync="DialogVisible" :close-on-click-modal="false" :destroy-on-close="true" title="修改密码" width="30%" append-to-body center @close="resetForm('ruleForm')"> <span>this is a dialog</span> <span slot="footer" class="dialog-footer"> <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button> <el-button @click="resetForm('ruleForm')">重置</el-button> </span> </el-dialog> </span> </template>
<script> export default { name: 'ResetPassword', data() { return { DialogVisible: false, } }, methods: { submitForm(formName) { const that = this this.$refs[formName].validate((valid) => { if (valid) { } else { } }) }, resetForm(formName) { this.$refs[formName].resetFields() }, openDialog() { this.DialogVisible = true } } } </script>
组件使用: <template> <div> <reset-Password/> </div> </template>
<script> import ResetPassword from '../../components/dialog/resetPassword' export default { name: 'AppMain', components: {ResetPassword}, data () { return {}; }, methods: {}, }; </script>
|