From 096f2bfe9ce1a9659282b2b1f994c89fea1a76a2 Mon Sep 17 00:00:00 2001 From: 梁灏 Date: Tue, 18 Jul 2017 14:15:57 +0800 Subject: [PATCH] fixed #1357 --- examples/routers/table.vue | 6 +++++- src/components/table/header.js | 16 ++++++++++++++++ src/components/table/table-head.vue | 13 ++++--------- 3 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 src/components/table/header.js diff --git a/examples/routers/table.vue b/examples/routers/table.vue index c9fdb31..9a9f96c 100644 --- a/examples/routers/table.vue +++ b/examples/routers/table.vue @@ -21,7 +21,11 @@ title: '姓名', key: 'name', width: 100, - fixed: 'left' + fixed: 'left', + sortable: true, + renderHeader: (h, params) => { + return h('Tag', params.index) + } }, { title: '年龄', diff --git a/src/components/table/header.js b/src/components/table/header.js new file mode 100644 index 0000000..ca3154a --- /dev/null +++ b/src/components/table/header.js @@ -0,0 +1,16 @@ +export default { + name: 'TableRenderHeader', + functional: true, + props: { + render: Function, + column: Object, + index: Number + }, + render: (h, ctx) => { + const params = { + column: ctx.props.column, + index: ctx.props.index + }; + return ctx.props.render(h, params); + } +}; \ No newline at end of file diff --git a/src/components/table/table-head.vue b/src/components/table/table-head.vue index 563e1d7..63d048b 100644 --- a/src/components/table/table-head.vue +++ b/src/components/table/table-head.vue @@ -10,7 +10,8 @@