init
This commit is contained in:
parent
a5321e843e
commit
8135a8c341
3 changed files with 34 additions and 1 deletions
|
@ -24,17 +24,23 @@
|
|||
:column="column"
|
||||
:index="index"
|
||||
:render="column.render"></table-expand>
|
||||
<table-slot
|
||||
v-if="renderType === 'slot'"
|
||||
:row="row"
|
||||
:column="column"
|
||||
:index="index"></table-slot>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import TableExpand from './expand';
|
||||
import TableSlot from './slot';
|
||||
import Icon from '../icon/icon.vue';
|
||||
import Checkbox from '../checkbox/checkbox.vue';
|
||||
import Tooltip from '../tooltip/tooltip.vue';
|
||||
|
||||
export default {
|
||||
name: 'TableCell',
|
||||
components: { Icon, Checkbox, TableExpand, Tooltip },
|
||||
components: { Icon, Checkbox, TableExpand, TableSlot, Tooltip },
|
||||
props: {
|
||||
prefixCls: String,
|
||||
row: Object,
|
||||
|
@ -107,6 +113,8 @@
|
|||
this.renderType = 'expand';
|
||||
} else if (this.column.render) {
|
||||
this.renderType = 'render';
|
||||
} else if (this.column.slot) {
|
||||
this.renderType = 'slot';
|
||||
} else {
|
||||
this.renderType = 'normal';
|
||||
}
|
||||
|
|
20
src/components/table/slot.js
Normal file
20
src/components/table/slot.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
export default {
|
||||
name: 'TableSlot',
|
||||
functional: true,
|
||||
inject: ['tableRoot'],
|
||||
props: {
|
||||
row: Object,
|
||||
index: Number,
|
||||
column: {
|
||||
type: Object,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
render: (h, ctx) => {
|
||||
return h('div', ctx.injections.tableRoot.$scopedSlots[ctx.props.column.slot]({
|
||||
row: ctx.props.row,
|
||||
column: ctx.props.column,
|
||||
index: ctx.props.index
|
||||
}));
|
||||
}
|
||||
};
|
|
@ -114,6 +114,11 @@
|
|||
name: 'Table',
|
||||
mixins: [ Locale ],
|
||||
components: { tableHead, tableBody, Spin },
|
||||
provide () {
|
||||
return {
|
||||
tableRoot: this
|
||||
};
|
||||
},
|
||||
props: {
|
||||
data: {
|
||||
type: Array,
|
||||
|
|
Loading…
Add table
Reference in a new issue