想实现的效果是如果有slot显示slot,没有则显示demo
<div>
<div class="demo" v-if="!$slots.default"><div>
<slot></slot>
</div>
或则
<template>
<div>
<div class="demo" v-if="isShow"></div>
<slot></slot>
</div>
</template>
<script>
export default {
computed: {
isShow () {
console.log(this.$slots)
return this.$slots.default
}
}
}
</script>
网友评论