有没有一种方法可以显示Vuetify加载器组件,直到所有元素都加载完毕?如果不是,它会暂时显示{{和}},而且不是很美观。
我有一个很大的页面,有很多物品,在每个物品上加上v-cloak
也不觉得很酷,我更喜欢显示一个装载器。
答案 0 :(得分:0)
在这种情况下,Vuetify overlay component并不是一个不错的选择。您可以选择带有不确定的加载程序的不透明叠加层,然后在加载完所有内容后将其隐藏:
<template>
<div>
<div id="the-content">
This is the stuff that gets hidden until it's loaded...
</div>
<v-overlay
:opacity="1"
:value="overlay"
>
<v-progress-circular indeterminate size="64">
Loading...
</v-progress-circular>
</v-overlay>
</div>
</template>
<script>
export default {
data: () => ({
overlay: true,
}),
mounted() {
// hide the overlay when everything has loaded
// you could choose some other event, e.g. if you're loading
// data asynchronously, you could wait until that process returns
this.overlay = false
},
}
</script>
注意:在此示例中,您不太可能看到加载叠加层,因为此页面上的内容需要很短的时间才能真正加载。