運用vue-cli做項目,如何向後臺請求真實的資料呢?
可以使用vue-resource
//get || post
this.$http.get(url).then((res) => {
// do something
}, (res) => {
// error callback
})
可以使用vue-resource進行請求
樓主可能遇到的是跨域問題?
如果後臺是php的話請在接收的方法中加入
header('Access-Control-Allow-Credentials:true');
header("Access-Control-Allow-Origin:*");
header('Access-Control-Allow-Headers:x-requested-with,content-type');
樓主的意思是怎麼請求後端數(shù)據(jù),並不是說沒有接口,。配置個代理程式就好了,不用跨域,在config下的index.js裡有個proxyTable設定下就好了。