v-show doesn't hide elements until I mount Vue

I createApp and mount it to <div>, which is just under <body>. I mount at just before </body> because the <div> have to exist before I mount to it.

My model's property is false so the elements with v-show should not be shown.

What happens is:

  1. <body> and <div>, which includes the elements with v-show, are loaded.
  2. They are all shown even though I don't want to see the elements with v-show.
  3. Vue hide the elements with v-show. At last, it's OK.

How can I show properly from the first sight?

I'm using Vue3 on Chrome.


#1 Answers

You can try adding the v-cloak directive to the div and the following style

[v-cloak] {
  display: none;
}

v-cloak docs: https://vuejs.org/v2/api/#v-cloak

Comments