[英]Vuejs - Passing parent component props to child element with the template
The problem I'm trying to solve is I want the child component to react when a v-expansion panel is expanded/contracted. 我要解决的问题是我希望子组件在v展开面板展开/收缩时做出反应。
Normally this would be trivial, however, I'm attempting to pass a value from a prop within a vuetify component to component via a scoped slot. 通常这是微不足道的,但是,我试图通过范围化的插槽将值从vuetify组件内的prop传递到组件。 Because I'm rendering the child components within a loop, I can't just use Data to bind the prop.
因为我是在循环中渲染子组件,所以不能仅使用Data绑定道具。
<v-expansion-panel expand>
<v-expansion-panel-content
v-for="item in this.items"
:key="item.key">
<div slot="header">
content
</div>
<slot :items="item.children"></slot>
</v-expansion-panel-content>
</v-expansion-panel>
The v-expansion-panel-content has a prop called value. v-expansion-panel-content具有一个称为值的属性。 I need to bind that prop to the slot.
我需要将该道具绑定到插槽。 Ideally, I'd like to achieve something like this:
理想情况下,我想实现以下目标:
<slot :items="item.children" :panelValue="value"></slot>
Any ideas would be greatly appreciated. 任何想法将不胜感激。
I've solved this, but in a less than ideal way. 我已经解决了这个问题,但是方法不太理想。
<v-expansion-panel expand>
<v-expansion-panel-content
v-for="item in this.items"
:key="item.key"
v-model="item.isOpen">
<div slot="header">
content
</div>
<slot :items="item.children" :isVisible="item.isOpen"></slot>
</v-expansion-panel-content>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.