yarn add json-bigint
//或
npm install json-bigint
request.js中添加
import jsonBig from 'json-bigint'
const res = axios.create({
// 接口的基础连接
baseURL: 'http:// www.xxxxx.com/',
// 自定义返回的元素数据,axios会默认用JSON.parse
// `transformResponse` 在传递给 then/catch 前,允许修改响应数据
transformResponse: [
function (data) {
// 对 data 进行任意转换处理
try {
// 如果转换成功则返回转换的数据结果
const json = jsonBig({
storeAsString:true
})
return json.parse(data)
} catch (err) {
return data
}
}
]
})