rewrite App.vue with render function

This commit is contained in:
Pooya Parsa 2017-10-07 13:13:09 +03:30
parent 75350cdd78
commit 870cbd6278

View File

@ -1,12 +1,3 @@
<template>
<div id="__nuxt">
<% if (loading) { %><nuxt-loading ref="loading"></nuxt-loading><% } %>
<% if (layoutTransition) { %><transition name="<%= layoutTransition.name %>" mode="<%= layoutTransition.mode %>"><% } %>
<component v-if="layout" :is="nuxt.err ? 'nuxt' : layout" :key="layoutName"></component>
<% if (layoutTransition) { %></transition><% } %>
</div>
</template>
<script>
import Vue from 'vue'
<% if (loading) { %>import NuxtLoading from '<%= (typeof loading === "string" ? loading : "./components/nuxt-loading.vue") %>'<% } %>
@ -26,6 +17,25 @@ let resolvedLayouts = {}
export default {
head: <%= JSON.stringify(head) %>,
render(h, props) {
<% if (loading) { %>const loadingEl = h('nuxt-loading', { ref: 'loading' })<% } %>
const layoutEl = h(this.nuxt.err ? 'nuxt' : this.layout, {
key: this.layoutName
})
const transitionEl = h('transition', {
props: {
name: '<%= layoutTransition.name %>',
mode: '<%= layoutTransition.mode %>'
}
}, [ layoutEl ])
return h('div', [
<% if (loading) { %>loadingEl,<% } %>
transitionEl
])
},
data: () => ({
layout: null,
layoutName: ''