【发布时间】:2020-08-02 12:57:25
【问题描述】:
在我的 vue/cli 4 / Bootstrap 4.3 应用程序中,我使用 vue-tables-2 并读取服务器表 在这里实现https://matanya.gitbook.io/vue-tables-2/server-table
从服务器端(laravel 6)我返回:
return response()->json([
'data' => $activityLogs,
'count' => $activity_logs_count
], 200);
在控制台中我看到返回的数据:https://imgur.com/a/2iGUfKS
But in the console I have errors :
vue-tables-2: invalid 'count' property. Expected number, got undefined
...
set-data.js?7175:11 count equals undefined
...
vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in render: "TypeError: props.data.forEach is not a function"
...
found in
---> <RLTableBody>
<VtTableBody>
vue.runtime.esm.js?2b0e:1888 TypeError: props.data.forEach is not a function
at _default (VtTableBody.js?1a4e:36)
我认为返回数据的格式存在问题。 在 vue 文件中我有:
<div id="activity_logs_data_table">
<v-server-table :url="apiUrl + '/activity-logs-filter'" :columns="columns" :options="tableOptions">
</v-server-table>
</div>
...
tableOptions: {
// see the options API
requestFunction(data) {
this.is_page_loaded = false
let credentialsConfig= JSON.parse(JSON.stringify(settingCredentialsConfig))
credentialsConfig.headers.Authorization = 'Bearer ' + this.$parent.$parent.currentLoggedUserToken
return axios.get(this.url, {
params: data
}, credentialsConfig ).catch(function (error) {
console.log('requestFunction error::')
console.error(error)
})
} // requestFunction: (data) => {
},
...
"axios": "^0.19.0",
"vue": "^2.6.10",
"vue-tables-2": "^2.0.14"
哪种格式必须是返回数据的有效格式?
谢谢!
【问题讨论】:
标签: vuejs2 vue-tables-2