需要调用 this.getDict();方法获取数据,可以在页面使用
mounted() {
this.getDict();
this.getRows()
},
getDict() {
GetAll(this.query).then(res => {
this.rows = res.data.data
this.$set(this,'nameList',unified(this.rows))
console.log("this.nameList2", this.nameList)
})
console.log("this.nameList3", this.nameList)
},
<el-table-column label="菜单" min-width="250" align="center">
<template slot-scope="scope">
{{translate(scope.row.pid,nameList)}}
</template>
</el-table-column>
在列表页面菜单字段有个方法,根据pid到nameList寻找并显示菜单名称,
如果用this.getDict(); 方法获取,this.nameList2可以打印出数据,this.nameList3是空的,列表页面也是空的,
如果在computed里写死nameList,页面是可以显示菜单名称的
{{translate(scope.row.pid,nameList)} 这个方法没有问题
computed: {
nameList: function() {
return [{
'pid': '0001',
'label': '标题分类'
}, {
'pid': '0002',
'label': '新闻'
},
}
},