您知道从API加载所有包含的数据后如何获取数字行问题数组。我需要为分页表设置totalRows,但是this.questions = this.questions.lenght
无效,返回null。export default {
data() {
return {
questions: [],
fields: [
{ key: 'id', label: 'ID', sortable: true },
{ key: 'title', label: 'Title', sortable: true },
{ key: 'updated_at', label: 'Last update', sortable: true},
],
totalRows: 13,
currentPage: 1,
perPage: 5,
pageOptions: [5, 10, 15]
}
},
components: {},
created() {
axios.get('/api/question')
.then(res => this.questions = res.data.data)
.catch(error => console.log(error.response.data))
},
}
我还添加了返回我的API的内容questions:Array[10]
--0:Object
-----body:"Sed minima nemo fuga libero. Rerum incidunt odio voluptatem aut quidem consequuntur. Odio deserunt labore voluptatem quo aut atque nemo."
-----id:1
-----title:Object
-----updated_at:"1 tydzień temu"
-----user:"Ahmad Mills"