How to introduce naive-ui ? #682
-
I tried to introduce naive-ui in my vuepress with its default theme. It worked only when hot-updated, namely
My relevant codes are : markdown <ClientOnly>
<CustomComponent/>
</ClientOnly> vue component (registered in <template>
<ClientOnly>
<n-button>button</n-button>
</ClientOnly>
</template>
<script lang="ts" setup>
import {NButton} from "naive-ui";
</script> my
Is this a bug or does it require any additional steps ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
naive-ui may not support ssr rendering. There is one thing you should know: ClientOnly only render client on client side, so if the component calls client only variables in setup functions, (e.g.: But, when the component or the library itself are referencing those variables in code direct (probably context or outside component and functions), those variables will be accessed while parsing and loading that module. Also, the component is not allowed to access dom unless in Since I did not use native ui before, you should be better sure that it's ssr friendly, otherwise, you must take actions to make a workaround. Also make sure you are not affected by #585 |
Beta Was this translation helpful? Give feedback.
naive-ui may not support ssr rendering.
There is one thing you should know: ClientOnly only render client on client side, so if the component calls client only variables in setup functions, (e.g.:
window
,docuement
), it will still work.But, when the component or the library itself are referencing those variables in code direct (probably context or outside component and functions), those variables will be accessed while parsing and loading that module. Also, the component is not allowed to access dom unless in
onMounted
lifecycle.Since I did not use native ui before, you should be better sure that it's ssr friendly, otherwise, you must take actions to make a workaround.
Also make sure yo…