Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
444 views
in Technique[技术] by (71.8m points)

vue.js - 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.

question from:https://stackoverflow.com/questions/65858761/v-show-doesnt-hide-elements-until-i-mount-vue

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...