我试图在路由之间添加一个加载器,如 nuxt.js 文档中所示,但它不起作用。但我无法在应用程序启动之前添加启动画面。
我的components/loading.vue中的代码片段
<template>
<div v-if="loading" class="loading-page">
<p>Loading...</p>
</div>
</template>
<script>
export default {
data: () => ({
loading: false
}),
methods: {
start(){
this.loading = true
},
finish(){
this.loading = false
}
}
}
</script>
在nuxt.js.config
export default {
...
loading: '~/components/loading.vue'
...
}