Answer the question
In order to leave comments, you need to log in
How to get rid of flickering when loading elements hidden with v-if?
There are a few divs that are initially hidden like this,
where the variable is on=false from the start:<div v-if="(on)">
Vue ({
data: on=false
});
Answer the question
In order to leave comments, you need to log in
The template should not be in .html (which is loaded before Vue is initialized), but in the template property of the component being created
Vue.component('comp', {
template: '...'
});
new Vue({
el: '#app'
});
<div id="app"><comp></comp></div>
Firstly, if the element is likely to be visible on the page sooner or later, it is better to hide it with v-show, this is easier than rebuilding the DOM;
Secondly, if it flashes, then the flag of its display often changes;
Thirdly, you can use transition/transition-group so that it doesn't "flicker".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question