import("./assets/_hi_-kdq1g9hr.j..."/>

请教一下如何在 vue3 jsx 写法中使用 unplugin-vue-router 自动生成路由 jsx 中添加 meta.layout 信息?

43次阅读

共计 525 个字符,预计需要花费 2 分钟才能阅读完成。

正确的写法在 unplugin-vue-router 解析页面读取信息后生成的 route.ts 中会加入类似以下代码段的 meta 信息

{
    path: "/hi",
    name: "/hi",
    component: () => import("./assets/_hi_-kdq1g9hr.js"),
    /* no children */
    meta: {"layout": home}
  },

[正确运行] 原作者给出的是 vue 写法






meta:
  layout: home

[失败,没有 meta] 转换成 jsx 写法,使用 ”@vitejs/plugin-vue-jsx”: “^3.1.0”, 编译

import {defineComponent} from 'vue'

export default defineComponent({setup() {
    // your setup code here
    const {t} = useI18n()
    // eslint-disable-next-line unused-imports/no-unused-vars
    const {route} = useRoute()

    return () => (<>
        
{t('found') }
meta: layout: home ) }, })
正文完
 0