3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Nuxt.js【this.$nuxt.$loading.start is not a function 】エラーの対処法

Posted at

Nuxt.jsにて、

this.$nuxt.$loading.start is not a function 

上記エラーの対処法になります。

mountedで【this.$nuxt.$loading.start】を使用するとエラーがでる

<script>
export default {
  mounted() {
    this.$nuxt.$loading.start()

    setTimeout(() => this.$nuxt.$loading.finish(), 500)
  }
}
</script>

上記のように、 mountedでthis.$nuxt.$loading.startを使用するとthis.$nuxt.$loading.start is not a function のエラーがでます。

this.$nextTickを使うことで解決

<script>
export default {
  mounted() {
    this.$nextTick(() => {
      this.$nuxt.$loading.start()

      setTimeout(() => this.$nuxt.$loading.finish(), 500)
    })
  }
}
</script>

上記のようにthis.$nextTickを使用することでエラーが解消できました。
this.$nextTickは、DOMを更新後、その更新済みのDOMに対して何らかの処理をすることが可能です。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?