mirror of https://github.com/vuejs/vitepress
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
580 B
24 lines
580 B
import { defineComponent, onMounted, ref } from 'vue'
|
|
|
|
export const ClientOnly = defineComponent({
|
|
props: {
|
|
isClientOnly: {
|
|
type: Boolean,
|
|
default: true
|
|
}
|
|
},
|
|
setup(props, { slots }) {
|
|
// Programmatically determine if this component should be
|
|
// client-only based on the presence of the isClientOnly attribute.
|
|
if (!props.isClientOnly) return () => slots.default?.(props) || null
|
|
|
|
const show = ref(false)
|
|
|
|
onMounted(() => {
|
|
show.value = true
|
|
})
|
|
|
|
return () => (show.value && slots.default ? slots.default() : null)
|
|
}
|
|
})
|