Nuxt/lib/app/App.vue

45 lines
1.0 KiB
Vue
Raw Normal View History

2016-11-07 01:34:58 +00:00
<template>
<div id="app">
<% if (loading) { %><nuxt-loading ref="loading"></nuxt-loading><% } %>
2016-11-07 01:34:58 +00:00
<router-view v-if="!err"></router-view>
<nuxt-error v-if="err" :error="err"></nuxt-error>
2016-11-07 01:34:58 +00:00
</div>
</template>
<script>
import NuxtError from '<%= components.ErrorPage %>'
<% if (loading) { %>import NuxtLoading from '<%= (typeof loading === "string" ? loading : "./components/Loading.vue") %>'<% } %>
2016-11-07 01:34:58 +00:00
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()
2016-11-07 01:34:58 +00:00
}
<% } %>
return this.err
}
},
components: {
NuxtError<%= (loading ? ',\n\t\tNuxtLoading' : '') %>
2016-11-07 01:34:58 +00:00
}
}
</script>
<% css.forEach(function (c) { %>
<style src="<%= (typeof c === 'string' ? c : c.src) %>" lang="<%= (c.lang ? c.lang : 'css') %>"></style>
<% }) %>