Vue2实时监听表单变化的示例讲解

今天小编就为大家分享一篇Vue2实时监听表单变化的示例讲解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

如下所示:

<template> <section> <el-dialog :title="formTitle" :visible.sync="dialogFormVisible" :before-close="cancel"> <el-form :model="form" :rules="rules" ref="form"> </el-form> <div slot="footer"> <el-button size="medium" type="primary" @click="addSubmit" :loading="addLoading" :disabled="unChange">确 定</el-button> </div> </el-dialog> </section> </template>

<script> export default { props: ["dialogFormVisible","form","formTitle"], data() { return { unChange: true, preForm: JSON.parse(JSON.stringify(this.form)) //深拷贝对象 }; }, watch: { form:{ handler:function(nowVal,oldVal){ var $this = this; for(let i in $this.form){ if(nowVal[i] != $this.preForm[i]) { $this.unChange = false; break; }else { $this.unChange = true; } } }, deep:true } }, methods: { addSubmit() { var $this = this; } }, mounted() { var $this = this; } }; </script>

以上这篇Vue2实时监听表单变化的示例讲解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/c259ccaaad29672c93acc9e6b173b73c.html