반응형
"슬롯" 구성 요소가 표시되지 않음
다음 구성 요소를 사용하여 동적 구성 요소를 구축하려고 함slot
그러기 위해서, 나는 이것을 가지고 있다.layout
:
<template>
<div class="container-fluid">
<div class="row">
LAYOUT NOT CONNECTED
<slot />
</div>
</div>
</template>
이 있는 곳에는<slot>
.
나는 이 구성 요소를 가지고 있다.login
:
<template>
<div>bla bla</div>
</template>
내 앱은:
<template>
<component :is="layout">
<router-view />
</component>
</template>
<script>
const default_layout = 'layout-not-connected'
export default {
computed: {
layout() {
console.log(this.$route.meta.layout || default_layout)
return (this.$route.meta.layout || default_layout)
}
},
...
그리고 내 경로로는 다음과 같다.
{
path: '/login',
name: 'Login',
meta: { layout : 'layout-not-connected' },
component: Login
},
결과는 오직 그것뿐입니다.LAYOUT NOT DISPLAYED
로그인 컴포넌트가 아니라 디스플레이 된다.
내 실수는 어디 있지?
솔루션 1
명명된 경로를 사용해 보십시오.
<template>
<component :is="layout">
<router-view name="a" />
</component>
</template>
라우터 인스턴스 동안:
const router = new VueRouter({
routes: [
{
path: '/',
components: {
default: Foo,
a: Bar,
}
}
]
})
솔루션 2
실제 라우터 뷰를 유지하고 일치하는 라우터 객체가 에 있는지 확인routes
배열하다
<template>
<component :is="layout">
<router-view />
</component>
</template>
및 라우터 인스턴스:
const router = new VueRouter({
routes: [
// dynamic segments start with a colon
{ path: '/user/:id', component: User }
]
})
참조URL: https://stackoverflow.com/questions/64595880/the-slot-component-is-not-displayed
반응형
'IT이야기' 카테고리의 다른 글
페이지 로드를 계속 허용하는 Vue 라우터 가드 방법 (0) | 2022.03.26 |
---|---|
둘 중 어느 것이 더 나은가? 아니면 토속적인가? (0) | 2022.03.26 |
릴리스 후 네이티브 ScrollView 스냅을 다시 맨 위로 이동 (0) | 2022.03.26 |
데이터 테이블에서 "사용자 정의 필터" 프로펠러를 시각적으로 사용하는 방법또는 헤더로 필터링할 사용자 정의 필터를 만드는 방법 (0) | 2022.03.26 |
라우터는 왜 이다.밀어서 안 되는 거야?[Vue3] [Vuex4] (0) | 2022.03.26 |