vue-awesome-swiper icon indicating copy to clipboard operation
vue-awesome-swiper copied to clipboard

Swiper causes Vue hydration issue

Open hemmoleg opened this issue 3 years ago • 4 comments

Simply adding the swiper to a page like this: <swiper ref="mySwiper" :options="swiperOptions"></swiper> causes the virtual DOM tree not matching server side rendered content. [Vue warn]: The client-side rendered virtual DOM tree is not matching server-rendered content. This is likely caused by incorrect HTML markup, for example nesting block-level elements inside <p>, or missing <tbody>. Bailing hydration and performing full client-side render. The generated HTML in the browser then looks like this: <div class="swiper-container swiper-container-initialized swiper-container-horizontal swiper-container-pointer-events"><div class="swiper-wrapper" style="transition-duration: 0ms;"></div></div>

What exactly is causing the error and how can it be solved?

hemmoleg avatar Aug 31 '21 10:08 hemmoleg

Are you using nuxt?

thomas4Bitcraft avatar Sep 29 '21 08:09 thomas4Bitcraft

Yes.

hemmoleg avatar Oct 21 '21 15:10 hemmoleg

I wrapped swiper component inside the client-only nuxt component tag and it fixed it

<client-only> <swiper ref="mySwiper" > ... </swiper> </client-only>

andrscyv avatar Feb 12 '22 18:02 andrscyv

I wrapped swiper component inside the client-only nuxt component tag and it fixed it

<client-only> <swiper ref="mySwiper" > ... </swiper> </client-only>

but if you did this wrap with code client-only, the html code will lose these seo related info. so Does anyone can fix this issue or can you give us any advice?

skylingfly avatar Mar 04 '23 11:03 skylingfly