vue+typescript的项目
<Form-item label="会员:" prop="username">
<Row>
<Col>
<Input v-model="formValidate.username" style="width:863px;"></Input>
<span style="color:red;">{{tip}}</span>
<span style="color:red;">*</span>
</Col>
</Row>
</Form-item>
reset() {
let obj: any = this.$refs['formValidate']
obj.resetFields()
}
@Watch('$route')
onRoute(to: any) {
this.reset()
}
由于我是需要跳转页面,所以才把reset()放在onRoute里面的
它提示的indexof of "undefined"如下:
我编辑的页面表单有数据它好像就不会报错,表单没有数据的时候,它是最容易报错的...
它提示的indexOf of undefined,好像在说我的prop如果是数值类型的就没有indexOf,但是我把prop都改成字符串类型的了,它还是报错
这个bug有时有,有时没有,有点奇怪啊,help~
你的 FormItem 是不是有某个用了 v-if 当你第一次 resetFields 的时候 v-if="true", 下一次 resetFileds 的时候 v-if="false" 也就是这个FormItem 所绑定的 props 找不到了就会报这个错,改成 v-show 就不会有问题了