【问题标题】:how to pass slot/data to inertia layout component如何将插槽/数据传递给惯性布局组件
【发布时间】:2021-09-06 19:59:06
【问题描述】:

如何在惯性中将插槽或道具传递给layout 组件?

例如,这里有一个ForgotPassword 组件:

<template>
    <slot name="title">Forgot Password</slot>

    Forgot pw stuff goes here...
</template>

<script>
import CardLayout from "@/Layouts/CardLayout";

export default {
    layout: CardLayout,
}

这里是CardLayout 组件:

<template>
    <h1>{{ $slots.title }}</h1>

    <slot/>
</template>

h1 标签内没有任何显示...

【问题讨论】:

    标签: laravel vue.js inertiajs


    【解决方案1】:
    // CardLayout
    <template>
        <h1><slot name="title" /></h1>
        <slot />
    </template>
    
    // ForgotPassword
    <template>
        <template #title>Forgot Password</template>
    
        Forgot pw stuff goes here...
    </template>
    

    【讨论】:

    • 不适合我。它返回export 'render' (imported as 'render') was not found。如何解决这个问题?
    猜你喜欢
    • 1970-01-01
    • 2020-03-12
    • 2018-09-14
    • 2020-12-01
    • 2011-07-06
    • 1970-01-01
    • 2020-04-23
    • 2017-12-06
    • 1970-01-01
    相关资源
    最近更新 更多