2018-07-16 22:22:55 +08:00
|
|
|
<script>
|
|
|
|
|
// 组件
|
|
|
|
|
import d2ContainerFull from './components/d2-container-full.vue'
|
|
|
|
|
import d2ContainerFullBs from './components/d2-container-full-bs.vue'
|
2018-07-21 12:44:47 +08:00
|
|
|
import d2ContainerGhost from './components/d2-container-ghost.vue'
|
2018-07-21 13:27:35 +08:00
|
|
|
import d2ContainerGhostBs from './components/d2-container-ghost-bs.vue'
|
2018-07-21 14:13:25 +08:00
|
|
|
import d2ContainerCard from './components/d2-container-card.vue'
|
2018-07-21 15:09:30 +08:00
|
|
|
import d2ContainerCardBs from './components/d2-container-card-bs.vue'
|
2018-07-16 22:22:55 +08:00
|
|
|
export default {
|
|
|
|
|
name: 'd2-container',
|
|
|
|
|
props: {
|
|
|
|
|
// 容器样式
|
|
|
|
|
type: {
|
|
|
|
|
type: String,
|
|
|
|
|
required: false,
|
2018-07-18 08:30:51 +08:00
|
|
|
default: 'full'
|
2018-11-14 10:25:38 +08:00
|
|
|
},
|
|
|
|
|
// 滚动优化
|
|
|
|
|
betterScroll: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
required: false,
|
|
|
|
|
default: false
|
2018-07-16 22:22:55 +08:00
|
|
|
}
|
2018-11-14 10:25:38 +08:00
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
// 始终返回渲染组件
|
|
|
|
|
component () {
|
|
|
|
|
if (this.type === 'card' && !this.betterScroll) return d2ContainerCard
|
|
|
|
|
if (this.type === 'card' && this.betterScroll) return d2ContainerCardBs
|
|
|
|
|
if (this.type === 'ghost' && !this.betterScroll) return d2ContainerGhost
|
|
|
|
|
if (this.type === 'ghost' && this.betterScroll) return d2ContainerGhostBs
|
|
|
|
|
if (this.type === 'full' && !this.betterScroll) return d2ContainerFull
|
|
|
|
|
if (this.type === 'full' && this.betterScroll) return d2ContainerFullBs
|
|
|
|
|
else {
|
|
|
|
|
return 'div'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
render (h) {
|
|
|
|
|
const slots = [
|
|
|
|
|
h('div', this.$slots.default)
|
|
|
|
|
]
|
|
|
|
|
if (this.$slots.header) slots.push(h('div', { slot: 'header' }, [ this.$slots.header ]))
|
|
|
|
|
if (this.$slots.footer) slots.push(h('div', { slot: 'footer' }, [ this.$slots.footer ]))
|
|
|
|
|
return h('div', {
|
|
|
|
|
ref: 'container',
|
|
|
|
|
attrs: {
|
|
|
|
|
'class': 'container-component'
|
|
|
|
|
}
|
|
|
|
|
}, [
|
|
|
|
|
h(this.component, {
|
|
|
|
|
props: this.$attrs,
|
|
|
|
|
on: {
|
|
|
|
|
scroll: e => this.$emit('scroll', e)
|
|
|
|
|
}
|
|
|
|
|
}, slots)
|
|
|
|
|
])
|
2018-07-16 22:22:55 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|