【发布时间】:2021-08-05 05:02:26
【问题描述】:
我正在尝试在 Laravel 8.38 - InertiaJS 0.8.4 上构建一个应用程序,我正在使用 Vue 3 作为我的前端堆栈。
我有多个布局需要全局注册为Vue 组件,以便我可以在任何地方的应用程序中使用它。我做不到,我的代码:
import { createApp, h } from 'vue';
import { App as InertiaApp, plugin as InertiaPlugin } from '@inertiajs/inertia-vue3';
const el = document.getElementById('app');
const app = createApp({
render: () =>
h(InertiaApp, {
initialPage: JSON.parse(el.dataset.page),
resolveComponent: (name) => require(`./../Pages/${name}`).default,
}),
})
.mixin({ methods: { route } })
.use(InertiaPlugin);
app.component('app-market', () => import('./../layouts/AppMarketLayout')); //trying to import layout
app.mount(el);
在页面内部我试图调用这个布局组件:
<template>
<div>
<app-market-layout></app-market-layout>
</div>
</template>
无法获取,控制台中没有错误。
【问题讨论】:
-
您注册了一个
app-market组件,但您的标记使用了app-market-layout。
标签: laravel vue.js vuejs3 inertiajs