发表于: 2020-06-24 20:23:59
1 1985
今天完成的事情:
1.回顾任务
明天计划的事情:
1.回顾任务
遇到的问题和收获:
在列表页选好类型后,搜索
然后点击到新增或者编辑,在此页面刷新,然后再返回到列表页.此时在列表页进行清空操作,发现清空无效,状态依然是当前状态
原因:
this.$refs[formName].resetFields();
清空是用的这个指令清空,根据查到的资料
resetFields()方法的目的是给表单赋初始值。
正常的写法这个初始值是在form表单的生命周期的mounted的时候被赋初始值的。
所以在form表单的生命周期的mounted之前赋值了,后面调用resetFields()方法,form表单的值是不会被清空的,因为初始值变成了编辑的时候赋值的值。
我在created里面进行了初始赋值操作, resetFields()这个方法的初始值是在mounted里面赋值的.现在把赋值操作改到mounted里.
//将保存在路由参数里的值赋予数据对应的
this.queryInfo.size = Number(this.$route.query.numPage ? this.$route.query.numPage : this.queryInfo.size)
this.queryInfo.page = Number(this.$route.query.currentPage ? this.$route.query.currentPage : this.queryInfo.page)
// this.queryInfo.size = Number(this.$route.query.numPage)
// this.queryInfo.page = Number(this.$route.query.currentPage)
this.queryInfo.type = this.$route.query.type ? this.$route.query.type : ''
this.queryInfo.status = this.$route.query.status ? this.$route.query.status : ''
this.queryInfo.startAt = this.$route.query.startAt
this.queryInfo.endAt = this.$route.query.endAt
再优化下结构
<el-form-item label="类型" prop="type">
<el-select class="select-choice" v-model="queryInfo.type"
placeholder="请选择" value="">
<el-option v-for="item in typeMessage" :label="item.label" :value="String(item.value)"
:key="item.value">
</el-option>
</el-select>
</el-form-item>
评论