数据字典,不同页面传递参数。 dict.vue, 页面的id传递到 dictValue.vue 获取list.
//dict.vue 传参
showDictValue (item) {
this.$store.dispatch('getSystemDictId', item.id)
this.$router.push({
name: 'dictValue'
})
},
//dictValue.vue 接收参数.
import { mapGetters } from 'vuex'
systemDictId: null, //数据类型 null, 0 ,都试过
computed: {
...mapGetters({
systemDictId: 'getSystemDictId'
})
},
// dictValue 中的get List方法
getDictValueListById () {
this.axios.get(this.$http.httpUrl('/api/dictValue/selectByDictId'), {
params: {
pageNumber: this.currentPage,
pageSize: this.pageSize,
systemDictId: this.systemDictId,
}
}).then(response => {
//this.loading = true
this.dataList = response.data.data.dataList
this.totalCount = response.data.data.total
})
}
java后端:
@GetMapping("selectByDictId")
public Result<PageInfo<SystemDictValue>> selectByDictId(PageParam pageParam, SystemDictValue systemDictValue) {
LambdaQueryWrapper<SystemDictValue> queryWrapper = Wrappers.<SystemDictValue>lambdaQuery()
.eq(SystemDictValue::getSystemDictId, systemDictValue.getSystemDictId());
return Result.success(systemDictValueService.selectPage(pageParam, queryWrapper));
}
调试结果
Field error in object 'systemDictValue' on field 'systemDictId': rejected value [NaN]; codes [typeMismatch.systemDictValue.systemDictId,typeMismatch.systemDictId,typeMismatch.java.lang.Integer,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [systemDictValue.systemDictId,systemDictId]; arguments []; default message [systemDictId]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Integer' for property 'systemDictId'; nested exception is java.lang.NumberFormatException: For input string: "NaN"]
前端结果:
状态码200,负载显示传递参数NaN
学习阶段,不是特别懂别喷,最好能远程帮忙看看。
收起