前端代码:

data() {
return {
listQuery: {
date: [],
}
}
},
//查询列表信息
getList() {
if (this.listQuery.date == null || this.listQuery.date.length != 2) {
this.$message.warning("请选择时间后查询")
return
}
this.listLoading = true
console.log(this.listQuery) // {date:["2020-10-06","2020-11-06"]}
accDrainageQuery.getList(this.listQuery).then(res => {
this.list = res.data
this.listLoading = false
this.$refs.dataChart.list = res.data
this.$refs.dataChart.formatdata()
}).catch(err => {
console.log(err)
})
},

后端代码:

后端用String接收,

注意:前端axios传递一个包含数组的对象{date:["2020-10-06","2020-11-06"]}到后台,会自动转换成字符串2020-10-06,2020-11-06,我们再用String split[] = date.split(",")分割成字符串数组。

 

@GetMapping("/list")
public Result getList(String date) {
    return officialAccoutService.getList(date);
}
String split[] = date.split(",");

后端用List接收,

@GetMapping("/list")
public Result getList(@RequestParam List date) {

}

 

posted on 2020-11-06 22:45  周文豪  阅读(3185)  评论(0编辑  收藏  举报