Skip to content

使用须知

TableRender 分页请求数据格式处理

json
{
    "code": 200,
    "data": {
        "list": [],
        "total": 0
    }
}
{
    "code": 200,
    "data": {
        "list": [],
        "total": 0
    }
}

组件内部默认按照上面数据格式解析

js
const { list, total } = res.data
const { list, total } = res.data

假设未返回以上格式,组件内容无法正常解析,导致页面数据空白,可借助 formatData 处理。

js
import { defineTRConfig } from '@hamlet/render'

const config = defineTRConfig({
    formatData(res) {
        return {
            list: [],
            total: res.x,
        }
    },
})
import { defineTRConfig } from '@hamlet/render'

const config = defineTRConfig({
    formatData(res) {
        return {
            list: [],
            total: res.x,
        }
    },
})