[Vuejs]-Using v-cloak not working on asynchronous requests

0👍

I think there might be a misunderstanding of what v-cloak does.

v-cloak

This directive will remain on the element until the associated Vue instance finishes compilation.

if you want to hide something while something is loading, you need to manage the state and the loader yourself.

Usually this is done with something like a computed that is updated once data is loaded, which toggles the loader component for the other components using v-if or v-show

here is a simplified example…

<template>
  <MySpinner v-if="loading"/>
  <MyTable v-else :data="myAsynchData"/>
<template>

<script>
//... some code here
  computed: {
    loading => this.myAsynchData == undefined
  }
//... more code
</script>

Leave a comment