路由跳转发现用query传数组时,如果数组长度为1,跳转页面后拿到的是数组没问题,但是刷新页面时,数组会被转化为字符串,导致错误。
解决方案:
用JSON.parse(), JSON.stringify()
跳转时:
let query = {};
query = {
courseIds: JSON.stringify(selectedCoureseIds),
type: "shiShi"
};
this.$router.push({
path: "/admin/teacherFee",
query
});
接收时:
this.loadMany({
courseIds: JSON.parse(this.$route.query.courseIds)
}).then(res => {
if (res.responseHeader.status == 1) {
this.loading = false;
this.handleSummary(this.manyList);
} else {
this.loading = false;
}
});