mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
rewrite App.vue with render function
This commit is contained in:
parent
75350cdd78
commit
870cbd6278
@ -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: ''
|
||||
|
Loading…
Reference in New Issue
Block a user