Nuxt/lib/app/App.vue
Sébastien Chopin 2956e73c3e Loading component done
- Loading component working and customisable via nuxt.config.js (see
examples/async-data/)
- Accept callback for new Nuxt(options, cb) with cb(null, nuxt)
- Simplify async-data example
2016-11-07 19:21:32 +01:00

41 lines
903 B
Vue

<template>
<div id="app">
<% if (loading) { %><loading ref="loading"></loading><% } %>
<router-view v-if="!err"></router-view>
<error-page v-if="err" :error="err"></error-page>
</div>
</template>
<script>
import ErrorPage from '<%= components.ErrorPage %>'
<% if (loading) { %>import Loading from '<%= (typeof loading === "string" ? loading : "./components/Loading.vue") %>'<% } %>
export default {
data () {
return {
err: null
}
},
<% if (loading) { %>
mounted () {
this.$loading = this.$refs.loading
},
<% } %>
methods: {
error (err) {
err = err || null
this.err = err || null
<% if (loading) { %>
if (this.err && this.$loading && this.$loading.fail) {
this.$loading.fail()
}
<% } %>
return this.err
}
},
components: {
ErrorPage<%= (loading ? ',\n\t\tLoading' : '') %>
}
}
</script>