main.js中加入
// 解决long类型数字长度超过16位精度丢失
axios.defaults.transformResponse = function (data) {
if (typeof data === "string") {
try {
let c1 = data
.toString()
.replace(/:\d{17,}/g, ':"@rr$&"')
.replace(/@rr:\s/g, "")
.replace(/@rr:/g, "");
let c2 = c1
.replace(/:\d{1,}\.\d+/g, ':"@rr$&"')
.replace(/@rr:\s/g, "")
.replace(/@rr:/g, "");
data = JSON.parse(c2);
} catch (e) {
console.log(e);
/* Ignore */
}
}
return data;
};
网友评论