vue form表单提交



    
        
            
                v-model="dialog.form.imei"
            
        
    





const defaultRole = {
    imei:"",
}

data(){
    return{
        dialog:{
            title:'',
            dialogState:false,
            form:Object.assign({},defaultRole),
            rules:{
                imei:[{required:true,message:"请输入设备编码",trigger:"blur"}]
            }
        }
    }
}

//新增
addForm(){
    this.dialog.form = Object,assign({},defaultRole)
    this.dialog.dialogState = true;
}
    
//提交
submitForm(formName){
    this.$refs[formName].validate((valid)=>{
        if(valid){  //满足要求
            
            //成功之后
            this.resetDialog(formName)
        }       
    })
}

//清空form
resetDialog(formName){
    this.dialog.dialogState = false;
    this.$refs[formName].resetFields();
}

你可能感兴趣的:(vue,vue.js,javascript,vue)