1.Form必须要有ref属性
2.Form必须绑定:model
<Form ref="submitUser" :model="submitUser">
</FormItem>
3.Form的FormItem中必须要有prop属性
<FormItem prop="realName">
</FormItem>
下面附上代码:
html部分:
<Form ref="submitUser" :model="submitUser">
<FormItem prop="realName">
<Input type="text" v-model="submitUser.realName" placeholder="姓名"></Input>
</FormItem>
<FormItem prop="identityNuber">
<Input type="text" v-model="submitUser.identityNumber" placeholder="身份证号码"></Input>
</FormItem>
<FormItem prop="mobileNumber">
<Input type="text" v-model="submitUser.mobileNumber" placeholder="手机号码"></Input>
</FormItem>
<FormItem prop="telePhoneNumber">
<Input type="text" v-model="submitUser.telePhoneNumber" placeholder="固定号码"></Input>
</FormItem>
<FormItem>
<Button type="info" @click="query">查询</Button>
<Button @click="handleReset('submitUser')" style="margin-left: 8px;" type="info">Reset</Button>
</FormItem>
</Form>
javascript部分:
<script>
export default {
data () {
return {
submitUser:{
realName:'',
identityNumber:'',
mobileNumber:'',
telePhoneNumber:''
},
queryUser:{
domicile:'',
currentAddress:'',
familyStatus:'',
workStatus:'',
emergencyContact:'',
familyContact:'',
familyContactRelationShip:'',
familyContactPhone:'',
contactPerson:'',
contactPersonRelationShip:'',
contactPersonPhone:'',
familyNum:'',
permanentResidence:'',
familyIncome:'',
sourceIncome:'',
illInfo:'',
heartIll:'',
highBlood:'',
stroke:'',
asthma:'',
healthFile:'',
hospital:'',
hospitalPhone:'',
belongProperty:'',
propertyName:'',
propertyPhone:'',
area:'',
streetJW:'',
JWPhone:'',
belongStreetPhone:'',
belongPolice:'',
belongPoliceMan:'',
belongPoliceManPhone:'',
intersection:'',
building:'',
postalCode:'',
workUnit:'',
workPhone:'',
workLinkMan:'',
uselanguage:'',
userType:'',
description:'',
user:{
realName:'',
sex:'',
birthday:'',
mobileNumber:'',
telePhoneNumber:'',
headImage:'',
identityNumber:'',
createDate:''
}
}
}
},
methods:{
handleReset (name) {
this.$refs[name].resetFields();
}
}
}
</script>
如有不对后续会继续更改。