fix table api

pull/9/head
tangjinzhou 2018-04-02 09:48:03 +08:00
parent 849d7b9bf1
commit ab1ff471c1
5 changed files with 26 additions and 12 deletions

View File

@ -14,6 +14,9 @@ Simple table with actions.
<template slot="name" slot-scope="text">
<a href="#">{{text}}</a>
</template>
<template slot="customTitle">
<span><a-icon type="smile-o" /> Name</span>
</template>
<template slot="action" slot-scope="text, record">
<span>
<a href="#">Action 一 {{record.name}}</a>
@ -29,10 +32,10 @@ Simple table with actions.
</template>
<script>
const columns = [{
title: 'Name',
dataIndex: 'name',
key: 'name',
slotScopeName: 'name',
slots: { title: 'customTitle' },
scopedSlots: { customRender: 'name' },
}, {
title: 'Age',
dataIndex: 'age',
@ -44,7 +47,7 @@ const columns = [{
}, {
title: 'Action',
key: 'action',
slotScopeName: 'action',
scopedSlots: { customRender: 'action' },
}];
const data = [{

View File

@ -26,7 +26,7 @@ Add border, title and footer for table.
const columns = [{
title: 'Name',
dataIndex: 'name',
slotScopeName: 'name',
scopedSlots: { customRender: 'name' },
}, {
title: 'Cash Assets',
className: 'column-money',

View File

@ -54,7 +54,7 @@ export default {
title: 'name',
dataIndex: 'name',
width: '30%',
slotScopeName: 'name',
scopedSlots: { customRender: 'name' },
}, {
title: 'age',
dataIndex: 'age',
@ -64,7 +64,7 @@ export default {
}, {
title: 'operation',
dataIndex: 'operation',
slotScopeName: 'operation',
scopedSlots: { customRender: 'operation' },
}],
}
},

View File

@ -45,14 +45,25 @@ const Table = {
const columns = []
const { $slots, $scopedSlots } = this
cols.forEach(col => {
const { slotTitle, slotScopeName, ...restProps } = col
const { slots = {}, scopedSlots = {}, ...restProps } = col
const column = {
...restProps,
title: col.title || $slots[slotTitle],
}
if (slotScopeName && $scopedSlots[slotScopeName]) {
column.customRender = column.customRender || $scopedSlots[slotScopeName]
}
Object.keys(slots).forEach(key => {
const name = slots[key]
if (column[key] === undefined && $slots[name]) {
column[key] = $slots[name]
}
})
Object.keys(scopedSlots).forEach(key => {
const name = scopedSlots[key]
if (column[key] === undefined && $scopedSlots[name]) {
column[key] = $scopedSlots[name]
}
})
// if (slotScopeName && $scopedSlots[slotScopeName]) {
// column.customRender = column.customRender || $scopedSlots[slotScopeName]
// }
if (col.children) {
column.children = this.updateColumns(column.children)
}

View File

@ -3,7 +3,7 @@ const AsyncComp = () => {
const hashs = window.location.hash.split('/')
const d = hashs[hashs.length - 1]
return {
component: import(`../components/slider/demo/${d}`),
component: import(`../components/table/demo/${d}`),
}
}
export default [