请问IView中Talbe组件替换数据,
需要把“性别”一栏的值 “1|2” 分别显示为 “男|女”
下面是代码:
<template>
<tables ref="tables" v-model="usrListData" :columns="columns"/>
</template>
<script>
data () {
return {
columns: [
{title: '#', key: 'id'},
{title: '性别', key: 'sex'}
],
usrListData: []
},
mounted: function () {
getUsrList().then(res => {
res.data.result.forEach((info, index) => {
this.usrListData.push(res.data.result[index])
})
})
}
</script>
注意看文档..
render 自定义渲染列,使用 Vue 的 Render 函数。传入两个参数,第一个是 h,第二个为对象,包含 row、column 和 index,分别指当前行数据,当前列数据,当前行索引,详见示例。