我正在学习VueJS,并且我对ref,$ refs讲座有些困惑。我试图从vue的文档中了解它,但我没有得到我想知道的。将ref的内容从孩子传递给另一个VueJS子组件
举例来说,如果我有这个组件:
<user-item ref="details"></user-item>
,我使用
此得到这个组件中的数据$ refs.details
使用的这些数据用户父组件,因为此用户项是用户组件的子项。
<div id="User">
<user-item ref="details"></user-item>
</div>
在同一时间,我有叫另一个组件,让我们说权限的孩子也为用户组件:
<div id="User">
<user-item ref="details"></user-item>
<permissions></permissions>
</div>
在此权限组件,我需要同此$ refs.details。但是从我测试的东西,像一个实验,不起作用。
这只是一个简单的例子。
有人可以告诉我我该怎么做吗?
Kira我尝试使用这个。$ parent。$ refs.details和我得到:“无法读取未定义的属性”细节“ –
hmm你可以发布你的代码片段吗?它应该可以正常工作。 – Ikbel
'this。$ nextTick(()=> {this。$ parent。$ ref.details。开放({title = this.fullName,{ }); $ this.fullName( });'This is in the child and this in the parent:'this。$ nextTick(()=> {$ refs.details.open({title} this.fullName, }); });' –