Vue2實時監(jiān)聽表單變化的示例講解
更新時間:2018年08月30日 14:24:45 作者:xdhc304
今天小編就為大家分享一篇Vue2實時監(jiān)聽表單變化的示例講解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
如下所示:
<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" class="dialog-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實時監(jiān)聽表單變化的示例講解就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Vue報錯Module build failed: Error: Node&nb
這篇文章主要介紹了Vue報錯Module build failed: Error: Node Sass version 7.0.1 is incompatible with 4.0.0.解決方案,需要的朋友可以參考下2023-06-06vue3+vite3+typescript實現(xiàn)驗證碼功能及表單驗證效果
這篇文章主要介紹了vue3+vite3+typescript實現(xiàn)驗證碼功能及表單驗證效果,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-04-04