useHydration 组合
Quasar v2.15+
useHydration 可组合项在你为 SSR 构建时非常有用(但也可用于非 SSR 构建)。它是 QNoSsr 组件的底层实用程序。
¥The useHydration composable is useful when you build for SSR (but can be used for non SSR builds as well). It is a lower level util of the QNoSsr component.
语法(Syntax)
¥Syntax
import { useHydration } from 'quasar'
setup () {
const { isHydrated } = useHydration()
}
content_paste
function useHydration(): {
isHydrated: Ref<boolean>;
};
content_paste
示例(Example)
¥Example
<template>
<div>
<div v-if="isHydrated">
Gets rendered only after hydration.
</div>
</div>
</template>
<script>
import { useHydration } from 'quasar'
export default {
setup () {
const { isHydrated } = useHydration()
return {
isHydrated
}
}
}
</script>
content_paste