UNPKG

magiccube-vue3

Version:

vue3-js版组件库

32 lines (28 loc) 909 B
import { getCurrentInstance } from 'vue' const TableColumn = { name: 'McTableColumn', props: { label: String, width: [String, Number], align: { type: String, default: 'left' }, keyName: String, headerTip: String, headerTipWidth: [String, Number], headerTipHeight: [String, Number], }, setup(props, { slots }) { const instance = getCurrentInstance() const scope = instance.parent?.props?.data const index = instance.parent?.props?.rowIndex const data = (index || index === 0) && scope ? scope[index] : {} return () => slots.default ? slots.default({ item: data, rowIndex: index }) : '' } } TableColumn.install = (app) => { app.component(TableColumn.name, TableColumn) } const McTableColumn = TableColumn export { McTableColumn, McTableColumn as default }