You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vite Vue3 Vuetify报错:找不到布局项‘layout-item-0’如何解决?

解决Vuetify布局错误:Could not find layout item "layout-item-0"

错误原因

  1. 布局结构违反Vuetify规范:VAppBar被嵌套在VMain内部,而VAppBar作为全局应用栏组件,必须是VApp的直接子元素,与VMain同级。
  2. 页面内随意嵌套VAppBar:VAppBar属于Vuetify全局布局体系的一部分,页面内部直接使用会导致布局系统无法识别对应的布局项,触发错误。

解决方案

方案1:修正布局结构,替换页面内的VAppBar为VToolbar

步骤1:调整布局文件结构

将VAppBar从VMain中移出,改为VApp的直接子级:

<VApp>
  <VAppBar class="navbar" elevation="10"></VAppBar>
  <VMain>
    <VContainer
      fluid
      class="fill-viewport"
    >
      <RouterView :key="$route.fullPath" />
    </VContainer>
  </VMain>
</VApp>

步骤2:修改页面代码

把页面内的VAppBar替换为VToolbar(VToolbar是局部标题栏组件,适合页面内部使用):

<VToolbar density="comfortable" flat>
  <VToolbarTitle>
    Task Status
  </VToolbarTitle>
</VToolbar>

<VTable></VTable>

方案2:通过布局插槽实现页面级自定义VAppBar

如果需要不同页面显示不同的VAppBar内容,可通过插槽传递:

步骤1:修改布局文件,添加插槽

<VApp>
  <VAppBar class="navbar" elevation="10">
    <slot name="app-bar"></slot>
  </VAppBar>
  <VMain>
    <VContainer
      fluid
      class="fill-viewport"
    >
      <RouterView :key="$route.fullPath" />
    </VContainer>
  </VMain>
</VApp>

步骤2:在页面中使用插槽传递内容

<template #app-bar>
  <VAppBarTitle>
    Task Status
  </VAppBarTitle>
</template>

<VTable></VTable>

内容的提问来源于stack exchange,提问作者Tuong Mengleang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 18:16:32