getVoucherList thisloading = true; if !thisvoucherGroupId return; thisvoucherQueryParamaccountsId = thisaccountsId; thisvoucherQueryParamvoucherGroupId = thisv
The reason you are seeing [object%20Object] in the URL is because the query parameter in the getVoucherListById function is an object, and when you pass the query object as a parameter to params, it gets converted to a string representation of the object, which is [object%20Object].
To fix this, you need to correctly pass the query object to the params parameter using the URLSearchParams class. Uncomment the commented code in your code snippet and update it as follows:
getVoucherList() {
this.loading = true;
if (!this.voucherGroupId) {
return;
}
this.voucherQueryParam.accountsId = this.accountsId;
this.voucherQueryParam.voucherGroupId = this.voucherGroupId;
const params = new URLSearchParams(this.voucherQueryParam).toString();
getVoucherById(params) // Update this line
.then((res) => {
console.log(res, "getVoucherList");
})
.catch((error) => {
console.log(error);
});
},
// Query voucher group list
export function getVoucherListById(query) {
console.log(query, 'query'); // Update this line
return request({
url: '/financial/acvouchergrouprel/getVoucherListById',
method: 'get',
params: query
});
}
By passing the query object as params: query, it will be correctly serialized and appended to the URL, instead of being converted to [object%20Object].
原文地址: https://www.cveoy.top/t/topic/i4Nw 著作权归作者所有。请勿转载和采集!