如果要在特定路线上,我正在尝试将道具传递到路由器中的组件。
找到的所有教程仅使用一个组件,因此该道具可以简单地追加到列表中。
但是具有多个组件却无法正常工作。
name: "Room",
components: {
navbar: TitleRooms,
content: Room,
props: {
title: "message"
}
}
我尝试过,但是它什么也没做。
name: "Room",
components: {
navbar: {
TitleRooms,
props: {
title: "message"
}
},
content: Room
}
我也尝试过这个,但是它也不起作用。
是否可以使用多个嵌套的命名路由器视图正确执行此操作?
答案 0 :(得分:0)
实际上,您的路线会渲染 Room 组件,因此该组件会接收参数。 Navbar当然可以接收其道具,但是您应该通过gifts.reject!{ |gift| !product_keywords.include?(gift.product.name.downcase) }
来完成。做:
template
将“房间”组件中的<navbar :title="title" />
(从路径参数)绑定到导航栏
答案 1 :(得分:0)
据我所知,您正在尝试执行此操作:
name: "Room",
components: {
navbar: TitleRooms,
content: Room
},
props: {
navbar: {
title: "message"
},
content: false
}
这应该将值"message" for the prop
title to
TitleRooms . It won't pass any props to
Room . If you want to pass props to both components you can just change the
false`传递给包含所需道具的适当对象。