用vue-axios和axios后App.vue中this.seller = response.data.data需要俩个.data才有相同效果,请看代码。

来源:

sooaa3597221

2016-12-09

http://szimg.mukewang.com/58499d360001ab4913660746.jpg

http://szimg.mukewang.com/58499d710001ae9913660746.jpg

if中也要多加个.data

是不是因为vue-axios将json数据多包了一层?(我的猜想)

(header.vue中class=“avatar”写错了请不要在意,233)

写回答

1回答

ustbhuangyi

2016-12-09

看了你的问题,顺便去 github 上瞅了一眼 axios(https://github.com/mzabriskie/axios) 的文档。

Response Schema

The response for a request contains the following information.

{  // `data` is the response that was provided by the server
 data: {},  // `status` is the HTTP status code from the server response
 status: 200,  // `statusText` is the HTTP status message from the server response
 statusText: 'OK',  // `headers` the headers that the server responded with
 headers: {},  // `config` is the config that was provided to `axios` for the request
 config: {}
}

还是很清楚的,多包了一层 data。
然后我又顺便看了一下 vue-axios 的实现,基本上毫无意义,建议直接用 axios 吧。
PS: 遇到问题先查文档的习惯会比较好喔

0
0

Vue.js2.5+cube-ui重构饿了么App(经典再升级)

掌握Vue1.0到2.0再到2.5最全版本应用与迭代,打造极致流畅的WebApp

9868 学习 · 4162 问题

查看课程