使用mock, axios无法将出参自动转化为obj 大不了唱首歌 2020-12-31 72 阅读1分钟 解决方法: // 需要在transformResponse中使用 JSON.parse(res) function transformResponse(res) { const data = JSON.parse(res) } 原因: 1. 一般情况下, axios会自动处理json 2. 但使用transformResponse后, 需要手动处理转化 3. 使用axios.interceptors.request.use无需转化 -