vue-resource get请求的问题

clipboard.png如图想在页面加载的时候从数据库获取一些信息加载到页面上。但是回调函数中的ret获取到的是请求的一些信息
clipboard.png想要获取到后端传回来的数据应该怎么解决,求解答。

阅读 3.8k
3 个回答

一般是看 ret.data

看文档 https://github.com/pagekit/vu...

Response

A request resolves to a response object with the following properties and methods:

Property Type Description
url string Response URL origin
body Object, Blob, string Response body data
headers Header Response Headers object
ok boolean HTTP status code between 200 and 299
status number HTTP status code of the response
statusText string HTTP status text of the response
Method Type Description
text() Promise Resolves the body as string
json() Promise Resolves the body as parsed JSON object
blob() Promise Resolves the body as Blob object

这个回调函数不止只有一个参数的,你可以把参数都打出来看看

console.log(arguments)

我不是这种方式拿的,不是很清楚,应该有3个参数,第二个应该是你要的
或者是data里?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题