mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-05 03:47:12 +00:00
a1d78988c0
The intention of using r was to fix problems with windows paths, but calling r will try to resolve path as well. This was breaking original webpack resolve mechanism from node_modules
67 lines
1.7 KiB
Vue
67 lines
1.7 KiB
Vue
<template>
|
|
<div id="__nuxt">
|
|
<% if (loading) { %><nuxt-loading ref="loading"></nuxt-loading><% } %>
|
|
<component v-if="layout" :is="layout"></component>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
<% if (loading) { %>import NuxtLoading from '<%= (typeof loading === "string" ? loading : "./components/nuxt-loading.vue") %>'<% } %>
|
|
<% css.forEach(function (c) { %>
|
|
import '<%= wp(c.src || c) %>'
|
|
<% }) %>
|
|
|
|
let layouts = {
|
|
<%
|
|
var layoutsKeys = Object.keys(layouts);
|
|
layoutsKeys.forEach(function (key, i) { %>
|
|
"_<%= key %>": () => import('<%= layouts[key] %>' /* webpackChunkName: "layouts/<%= key %>" */)<%= (i + 1) < layoutsKeys.length ? ',' : '' %>
|
|
<% }) %>
|
|
}
|
|
|
|
export default {
|
|
head: <%= JSON.stringify(head) %>,
|
|
data: () => ({
|
|
layout: null,
|
|
layoutName: ''
|
|
}),
|
|
<% if (loading) { %>
|
|
mounted () {
|
|
this.$loading = this.$refs.loading
|
|
this.$nuxt.$loading = this.$loading
|
|
},
|
|
<% } %>
|
|
methods: {
|
|
setLayout (layout) {
|
|
if (!layout || !layouts['_' + layout]) layout = 'default'
|
|
this.layoutName = layout
|
|
let _layout = '_' + layout
|
|
this.layout = layouts[_layout]
|
|
return this.layout
|
|
},
|
|
loadLayout (layout) {
|
|
if (!layout || !layouts['_' + layout]) layout = 'default'
|
|
let _layout = '_' + layout
|
|
if (typeof layouts[_layout] !== 'function') {
|
|
return Promise.resolve(layouts[_layout])
|
|
}
|
|
return layouts[_layout]()
|
|
.then((Component) => {
|
|
layouts[_layout] = Component
|
|
return layouts[_layout]
|
|
})
|
|
.catch((e) => {
|
|
if (this.$nuxt) {
|
|
return this.$nuxt.error({ statusCode: 500, message: e.message })
|
|
}
|
|
console.error(e)
|
|
})
|
|
}
|
|
},
|
|
components: {
|
|
<%= (loading ? 'NuxtLoading' : '') %>
|
|
}
|
|
}
|
|
</script>
|
|
|