我是Vuejs 2的新手,目前正在执行一个项目。我正在使用vuetable-2在Vuejs 2中形成数据表。无法检索使用vuetable-2的数据,在Vuejs 2
我目前正面临一个问题,我无法使用属性,api-url,vuetable-2检索数据。
但是,我可以使用Axios和Global Axios Default Configs (将令牌传递给每个请求标头)从服务器检索数据。
以上示出了该图像2个部分:
1.使用vuetable-2的API-URL [该一个与错误403,禁止]
2.使用Axios的GET请求[成功地检索数据]
Vuetable-2 API-URL(API调用服务器):
<vuetable
ref="vuetable"
api-url="http://localhost:3000/api/staffs"
:http-options = "httpOptions"
:load-on-start = "loadOnStart"
:fields="['userId', 'name', 'username']"
></vuetable>
爱可信全球默认配置:
// Global axios default (config default that will be applied to every request)
var accessToken = window.localStorage.getItem('access_token')
axios.defaults.baseURL = 'http://localhost:3000/'
axios.defaults.headers.common['x-access-token'] = accessToken
上午我上遗漏了呢? : -/
也许你可以参考这个问题补充拦截您vuetable的要求https://stackoverflow.com/questions/39665244/vue-resource-interceptor-for-auth-headers –