小编Num*_*chi的帖子

如何在 Nuxt.js 中删除第一个加载圆 div (id="nuxt-loading")?

我从这里复制了一些文件:https : //codesandbox.io/s/github/nuxt/nuxt.js/tree/dev/examples/custom-loading? from- embed

  • 页面/about.vue
  • 页面/index.vue
  • 组件/loading.vue

并设置了 nuxt.config.js。见下文。

项目/组件/loading.vue

<template>
  <div v-if="loading" id="loader">
    <p>asdasdasd...</p>
  </div>
</template>

<script>
    export default {
        data: () => ({
            loading: false
        }),
        methods: {
            start () {
                this.loading = true
            },
            finish () {
                this.loading = false
            }
        }
    }
</script>
Run Code Online (Sandbox Code Playgroud)

项目/nuxt.config.js

{
    // ...
    loading: '~/components/loading',
    // ...
}
Run Code Online (Sandbox Code Playgroud)

下一步,我将 setTimeout ms 从 1000 设置为 60000 以进行测试。我在第一次加载时得到了另一个加载页面,而不是components/loading.vue。第二个和另一个加载很好,但不是第一个。

我在 F12 之后看到的,我在项目中找到了它。 项目/.nuxt/loading.html

<style>
#nuxt-loading {
  visibility: hidden;
  opacity: 0;
  position: …
Run Code Online (Sandbox Code Playgroud)

nuxt.js

3
推荐指数
1
解决办法
2332
查看次数

标签 统计

nuxt.js ×1