vant icon indicating copy to clipboard operation
vant copied to clipboard

fix: teleport ssr in vue3

Open zhangyuang opened this issue 3 years ago • 6 comments

Ref https://github.com/vuejs/vue-next/issues/5126

In vue3 ssr scene, teleport node must be wrapped by div node otherwise will cause hydrate not match. The changes has been test succeed in my ssr project

zhangyuang avatar Dec 24 '21 07:12 zhangyuang

cc @chenjiahan

zhangyuang avatar Dec 24 '21 07:12 zhangyuang

maybe we should wait for Vue to fix this bug?

chenjiahan avatar Dec 26 '21 14:12 chenjiahan

🤔maybe it“s a feature not bug

发自我的iPhone

------------------ Original ------------------ From: neverland @.> Date: Sun,Dec 26,2021 10:59 PM To: youzan/vant @.> Cc: yuuang @.>, Author @.> Subject: Re: [youzan/vant] fix: teleport ssr in vue3 (PR #10099)

maybe we should wait for Vue to fix this bug?

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

zhangyuang avatar Dec 26 '21 15:12 zhangyuang

I wonder if the method on the official document can solve this problem:

image

https://github.com/vuejs/vue-next/tree/master/packages/server-renderer#handling-teleports

I think we should not to change the way to use Teleport to avoid the SSR issue, Teleport is used by many components. Maybe it should be solved by Vue or SSR framework.

chenjiahan avatar Dec 26 '21 15:12 chenjiahan

The steps to fix the problem

1· In server side , insert teleport node to the exactly parent node by cheerio or jsdom to operate string of html

i have try it and find there must wrap teleport node inside div or fragment node

zhangyuang avatar Dec 26 '21 15:12 zhangyuang

We can wait for the reply off Vue offical, if this solution is confirmed, I will merge this PR ^_^

chenjiahan avatar Dec 27 '21 12:12 chenjiahan

This issue appears to have been fixed by Vue: https://github.com/vuejs/core/issues/5126#issuecomment-1129551606

chenjiahan avatar Sep 11 '22 01:09 chenjiahan