关于this.$refs[name].resetFields();

本文详细介绍了Element UI框架中的Form组件用法,包括必须设置的ref属性、model绑定,以及FormItem中的prop属性。通过具体代码示例,展示了如何创建输入框、按钮等元素,并实现表单重置功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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>

如有不对后续会继续更改。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值