【发布时间】:2021-06-20 01:55:52
【问题描述】:
在全新的 laravel 安装中,我试图按照惯性文档 https://inertiajs.com/pages 使布局持久化
app.js
require('./bootstrap');
// Import modules...
import { createApp, h } from 'vue';
import { App as InertiaApp, plugin as InertiaPlugin } from '@inertiajs/inertia-vue3';
import { InertiaProgress } from '@inertiajs/progress';
import AppLayout from '@/Layouts/AppLayout';
const el = document.getElementById('app');
createApp({
render: () =>
h(InertiaApp, {
initialPage: JSON.parse(el.dataset.page),
resolveComponent: name => import(`./Pages/${name}`)
.then(({ default: page }) => {
if (page.layout === undefined) {
page.layout = AppLayout
}
return page
}),
}),
})
.mixin({ methods: { route } })
.use(InertiaPlugin)
.mount(el);
InertiaProgress.init({ color: '#4B5563' });
Dashboard.vue(这里我用 div 替换了默认的 app-layout 包装器)
<template>
<div>
<template #header>
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
Dashboard
</h2>
</template>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-xl sm:rounded-lg">
<welcome />
</div>
</div>
</div>
</div>
</template>
<script>
import Welcome from '@/Jetstream/Welcome'
export default {
components: {
Welcome,
},
}
</script>
编译时出现此错误:
错误:缺少元素/if/for 节点的 Codegen 节点。申请 首先进行适当的转换。
我不明白那是什么意思。有 jetstream 和惯性的默认 laravel 应用不使用持久布局的原因吗?
【问题讨论】:
标签: layout laravel-8 inertiajs jetstream