I am using Advanced-Async-Components to load async component
after loading of the app. So I have tried the following code:
Index.vue
<template>
<div class="">
<Async></Async>
</div>
</template>
<script>
// async component
import LoadComp from '@/components/Loading'
import ErrorComp from '@/components/Error'
const Async = () => ({
// The component to load. Should be a Promise
component: import('@/components/Async'),
// A component to use while the async component is loading
loading: Load,
// A component to use if the load fails
error: ErrorComp,
// Delay before showing the loading component. Default: 200ms.
delay: 4000, // <--- this is not effecting the loading of component
// The error component will be displayed if a timeout is
// provided and exceeded. Default: Infinity.
timeout: 3000
})
export default {
components: {
Async
}
}
</script>
Async.vue
<template lang="html">
<div class="">
Lorem ipsum dolor sit amet, con .... very larger string/data
</div>
</template>
<script>
export default {
}
</script>
<style lang="css">
</style>
The above code works fine but it has no effect of delay
parameter (Index.vue). According to official docs delay
is Delay before showing the loading component. It should load the component after 4000ms
but it loads instantly.
Why is this happening?
Is there any other way to achieve this apart from using setTimeout
?
Additional Info
I used webpack
template to build the project using vue-cli
Vue version : ^2.4.2