问题描述
我想用来自 getters 的动态数据填充表格行。我需要帮助来遍历 contentOrders数组,并为每个 Content Type列分配来自数组的相应动态数据,并将相同的情况分配给 Workflow Type列 >
当我单击分页按钮时,实际数据会更新。
这是我的代码
<template>
<div class="container">
<Table :data="tableData" :columns="tableColumns" stripe></Table>
<div style="margin: 10px;overflow: hidden">
<div style="float: right;">
<Page :total="contentOrders.length" :current="1" @on-change="changePage"></Page>
</div>
</div>
</div>
</template>
<script>
import {mapGetters} from 'vuex';
export default {
name:'admin-content-orders',data:function(){
return{
tableData: this.mockTableData(),tableColumns:[
{
title:'Content Type',key:'content_type'
},{
title:'WorkFlow Type',key:'workflow_type'
}
],}
},computed:{
...mapGetters(['contentOrders'])
},methods:{
mockTableData:function(){
let data =[];
for(let i=0; i<5; i++){
this.$store.getters.contentOrders.forEach(function(value,key){
data.push({
content_type:value.content_type,workflow_type:value.workflow_type,})
})
}
return this.data
},changePage () {
// The simulated data is changed directly here,and the actual usage scenario should fetch the data from the server
this.tableData = this.contentOrders
console.log(this.tableData)
}
}
}
</script>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)