naive-ui/demo/utils/ComponentDemos.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

import { h } from 'vue'
import NCol from '../../src/grid/src/Col.vue'
import NRow from '../../src/grid/src/Row.vue'
2019-09-21 17:03:37 +08:00
export default {
name: 'ComponentDemos',
2019-10-12 19:08:11 +08:00
props: {
singleColumn: {
type: Boolean,
default: false
}
},
render () {
const defaultSlot = (this.$slots.default && this.$slots.default()) || []
// const anchorSlot = (this.$slots.anchor && this.$slots.anchor()) || []
2019-10-14 17:49:23 +08:00
// const anchor = [h('div', {
// staticClass: 'n-documentation-anchor'
// }, anchorSlot)]
2019-10-12 19:08:11 +08:00
if (this.singleColumn) {
2020-09-10 14:18:02 +08:00
return h(NRow, {
gutter: 16
}, {
default: () => h(NCol, { span: 24 }, this.$slots)
// h(NCol, { props: { span: 4 } }, anchorSlot)
})
2019-10-12 19:08:11 +08:00
} else {
const leftColumn = defaultSlot.filter((value, index) => index % 2 === 0)
const rightColumn = defaultSlot.filter((value, index) => index % 2 === 1)
2020-09-10 14:18:02 +08:00
return h(NRow, {
gutter: 16
}, {
default: () => [
h(NCol, { span: 12 }, {
default: () => leftColumn
}),
h(NCol, { span: 12 }, {
default: () => rightColumn
})
// h(NCol, { props: { span: 4 } }, anchor)
]
})
2019-10-12 19:08:11 +08:00
}
2019-09-21 17:03:37 +08:00
}
}