iview/src/components/layout/layout.vue

35 lines
825 B
Vue
Raw Normal View History

<template>
<div :class="wrapClasses"><slot></slot></div>
2017-12-18 18:36:50 +08:00
</template>
<script>
const prefixCls = 'ivu-layout';
export default {
name: 'Layout',
data () {
return {
hasSider: false
};
},
computed: {
wrapClasses () {
return [
`${prefixCls}`,
{
[`${prefixCls}-has-sider`]: this.hasSider
}
];
}
},
methods: {
findSider () {
return this.$children.some(child => {
2017-12-19 20:02:48 +08:00
return child.$options.name === 'Sider';
2017-12-18 18:36:50 +08:00
});
}
},
mounted () {
this.hasSider = this.findSider();
}
};
</script>