学无先后,达者为师

网站首页 编程语言 正文

element form表单数据未双向绑定

作者:chunchun_H 更新时间: 2022-10-14 编程语言
  • 最近在做项目表单部分,会遇到表单数据没有双向绑定,或者双向绑定延迟。
  • 直接看代码,在vue组件渲染的时候给表单赋初值。
//data中定义是空对象:serviceDetail:{},
//   初始化
    init(){
        if(this.moduleType == 'module'){
            this.moduleDetail = {
                    name: '',
                    userId:JSON.parse(sessionStorage.getItem('userInfo')).account,
                    remark:'',
                    status:1
            }
        }else{
            this.serviceDetail = {
                name: '',
                userId:JSON.parse(sessionStorage.getItem('userInfo')).account,
                usersId:'',
                remark:'',
                selStatus:'false',
                msgType:'',
                count:'',
                interval:'',
                isSendNight:'',
                isSendImediat:'',
                isSendUnDuty:'0',
                startTime:null,
                endTime:null,
                sendDay:'',
                sendHour:'',
                sendMin:'',
                sendStatus:'1',
                isCycleSend:'',
                cycleStatus:'1',
                cycleMonth:'2',
                cycleDay:'1',
                cycleHour:'1',
                regetData:'0',
                regetAddr:'',
                regetProtocol:'',
                status:2
            }
        }
    },
  • 在页面切换moduleType值是没有进行初始化表单,serviceDetail={},在此时拿到表单数据,直接赋值给serviceDetail,里面是找不到任何属性的,所有页面数据并未双向绑定。

原文链接:https://blog.csdn.net/organ_sweet/article/details/119993549

栏目分类
最近更新