Remember the problem of Vue using JS to initialize HTML after looping HTML with V-for once

Time:2021-10-6

When we use Vue’s V-for to loop a dataarr and then do JS initialization to add some JS effects to HTML, when we use js to select HTML, we find that HTML cannot be obtained and cannot be initialized. (I lost my memory again for a long time, so write it down):

watch:{
            Data: function() {// this is required because it is V-for. Data is the number of groups or objects you want to loop.
                this.$nextTick(function(){
                    this.init(); // Here, select the HTML element and initialize it.
                })
            }
        }

This work adoptsCC agreement, reprint must indicate the author and the link to this article

Everything is self-taught