Once upon a time there was a sweet little girl. Everyone who saw her liked her, but most of all her grandmother, who did not know what to give the child next. Once she gave her a little cap made of red velvet. Because it suited her so well, and she wanted to wear it all the time, she came to be known as Little Red Riding Hood.
—— —— —— — —— ————— ————— ——
We can specify data-loading-text to control the length of the placeholder displayed when loading.
<template><article><h1v-loading-preload="visible[0]"data-loading-text="2">{{ title }}</h1><divclass="content"v-loading-preload="visible[1]"data-loading-text="16">{{ content }}</div></article></template><script>exportdefault{data(){return{
title:'',
content:'',
visible:[false,false]}},
methods:{promise(ms, data){returnnewPromise(resolve=>{setTimeout(()=>{resolve(data)}, ms)})},asynctask(){this.title =awaitthis.promise(1600,'Little Red Riding Hood');this.$set(this.visible,0,true);this.content =awaitthis.promise(1800,'Once upon a time there was a sweet little girl.'+' Everyone who saw her liked her, but most of all her grandmother, '+'who did not know what to give the child next. '+'Once she gave her a little cap made of red velvet. Because it suited her so well, '+'and she wanted to wear it all the time, '+'she came to be known as Little Red Riding Hood.');this.$set(this.visible,1,true);}},mounted(){this.task()}}</script>
You can use the . (dot) operator after the command, followed by a number, which makes it easier and more beautiful to control the length of the placeholder, and also solves the problem that dataset does not exist in IE.
—— ——
—— —— —— — —— ————— ————— —— — ——— ——— —————
<template><article><h1v-loading-preload.4="visible[0]">{{ title }}</h1><divclass="content"v-loading-preload.24="visible[1]">{{ content }}</div></article></template>