javascript - nuxt js 中的异步组件延迟

标签 javascript vue.js delay nuxt.js async-components

异步组件延迟和加载不起作用。

我的代码:

<template>
   <div>
     <button @click="startMethod">start</button>
     <async-component v-if="start" />
   </div>
</template>

<script>
import Loading from '~/components/loading.vue'
import Error from '~/components/error'

const AsyncComponent = () => ({
  component: import('~/components/someComponent.vue'),
  loading: Loading, // not work
  error: Error, // good
  delay: 2000, // not work
  timeout: 3000 // good
});
export default {
  components: {
    AsyncComponent
  },
  data: () => ({
    start: false
  }),
  methods: {
    startMethod(){
      this.start = true
    }
  }
}
</script>

如何延迟加载组件的显示?而且我不明白为什么加载程序不显示并且延迟不起作用。

最佳答案

因为它是

Delay before showing the loading component. Default: 200ms.

引用:https://v2.vuejs.org/v2/guide/components-dynamic-async.html#Handling-Loading-State

尝试将它设置为 10 或 0 你会看到你的加载组件

关于javascript - nuxt js 中的异步组件延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58430023/

相关文章:

javascript - JS "Greater than"运算符;

php - 中止 jquery ajax 时中止 php 脚本执行

vue.js - 固定位置 vuetify 警报组件

javascript - 查找数组中的对象

javascript - jQuery 追加延迟

javascript - 如何使用 jQuery 变量隐藏 HTML 表格行

javascript - 如何按 desc 顺序对 x 轴进行排序

javascript - 为什么通过 Vue-router 传递数据返回 "[object Object]"?

javascript - Javascript 每五秒循环一次

JavaFX:在 TextArea 中显示文本,每行之间有延迟