Commit 8135a8c341d109bbf67005504f08ca5a802d582c

Authored by 梁灏
1 parent a5321e84

init

src/components/table/cell.vue
... ... @@ -24,17 +24,23 @@
24 24 :column="column"
25 25 :index="index"
26 26 :render="column.render"></table-expand>
  27 + <table-slot
  28 + v-if="renderType === 'slot'"
  29 + :row="row"
  30 + :column="column"
  31 + :index="index"></table-slot>
27 32 </div>
28 33 </template>
29 34 <script>
30 35 import TableExpand from './expand';
  36 + import TableSlot from './slot';
31 37 import Icon from '../icon/icon.vue';
32 38 import Checkbox from '../checkbox/checkbox.vue';
33 39 import Tooltip from '../tooltip/tooltip.vue';
34 40  
35 41 export default {
36 42 name: 'TableCell',
37   - components: { Icon, Checkbox, TableExpand, Tooltip },
  43 + components: { Icon, Checkbox, TableExpand, TableSlot, Tooltip },
38 44 props: {
39 45 prefixCls: String,
40 46 row: Object,
... ... @@ -107,6 +113,8 @@
107 113 this.renderType = 'expand';
108 114 } else if (this.column.render) {
109 115 this.renderType = 'render';
  116 + } else if (this.column.slot) {
  117 + this.renderType = 'slot';
110 118 } else {
111 119 this.renderType = 'normal';
112 120 }
... ...
src/components/table/slot.js 0 → 100644
  1 +export default {
  2 + name: 'TableSlot',
  3 + functional: true,
  4 + inject: ['tableRoot'],
  5 + props: {
  6 + row: Object,
  7 + index: Number,
  8 + column: {
  9 + type: Object,
  10 + default: null
  11 + }
  12 + },
  13 + render: (h, ctx) => {
  14 + return h('div', ctx.injections.tableRoot.$scopedSlots[ctx.props.column.slot]({
  15 + row: ctx.props.row,
  16 + column: ctx.props.column,
  17 + index: ctx.props.index
  18 + }));
  19 + }
  20 +};
0 21 \ No newline at end of file
... ...
src/components/table/table.vue
... ... @@ -114,6 +114,11 @@
114 114 name: 'Table',
115 115 mixins: [ Locale ],
116 116 components: { tableHead, tableBody, Spin },
  117 + provide () {
  118 + return {
  119 + tableRoot: this
  120 + };
  121 + },
117 122 props: {
118 123 data: {
119 124 type: Array,
... ...