Skip to content

How to show loading screen while form is loading? #228

Answered by adamberecz
pwicks86 asked this question in Questions
Discussion options

You must be logged in to vote

It's a bit tricky, but can be achieved:

<template>
  <Vueform
    v-if="loadStarted"
    v-show="loaded"  
    :schema
    @mounted="loaded = true"
  />
  <div v-show="!loaded">Loading...</div>
</template>

<script setup>
import { ref, computed, onMounted } from 'vue'

const loadStarted = ref(false)
const loaded = ref(false)

const schema = computed(() => {
  let schema = {}

  for (var i = 0; i < 1000; i++) {
    schema['text' + i] = { type: 'text' }
  }

  return schema
})

onMounted(() => {
  setTimeout(() => {
    loadStarted.value = true
  }, 0)
})
</script>

So first we hide the form with v-if. Then you can use setTimeout with 0 to make sure it only starts to render after the loader …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by pwicks86
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants