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
132 views
in Technique[技术] by (71.8m points)

javascript - Vue: Render v-for incrementally?

I have a v-for loop that renders a ChessGame component many times. However, the ChessGame component is complex, it takes a long time to load, several hundred milliseconds each, and the loop renders dozens of them. So the site is always stuck for several seconds and shows nothing before it shows all games.

Is there a hint that I can give Vue to rerender after each iteration, so that the page slowly fills with them? Or does the way Vue templating works not support this?

<ul v-for="(game, index) in competitions[selected_competition].games" v-bind:key="game.pgn">
  <div>
    <h4>Game {{ index+1 }}</h4>
    <ChessGame :id="'board_' + index" :ref="'board_' + index" :gameinfo="game" style="width: 400px"></ChessGame>
  </div>
</ul>

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

1 Reply

0 votes
by (71.8m points)

Is there a hint that I can give Vue to rerender after each iteration, so that the page slowly fills with them?

As far as I know, there is no such functionality in vue to slowly show your data, although what you can do until your data are ready is to show a skeleton loader.

This is a modern approach and almost every big company uses this technique, to indicate that something is loading until we serve the data.

I recommend you check this from vuetify: https://vuetifyjs.com/en/components/skeleton-loaders/


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

...