【发布时间】:2018-01-10 12:06:35
【问题描述】:
我有一个my-component1.js 定义如下;
export default Ember.Component.extend({
prop1: 'abc'
})
对应的模板my-component1.hbs如下;
{{#my-yield-component2}}
{{my-other-component3 field=(my-helper prop1)}}
{{/my-yield-component2}}
所以我想在 my-yield-component2 中显示/渲染 my-other-component3(因为我正在使用 yield)
在my-yield-component2里面,我有以下内容;
<div>My component with yield</div>
<div>{{yield}}</div>
我的问题是如何传递/获取对 my-component1 中实际定义的“prop1”的访问权限,但是因为我使用的是 yield,所以它将在 my-yield-component2 中呈现 所以我想知道如何传递“prop1”?
【问题讨论】:
-
没有错,它会起作用,这就是上下文组件的力量。
标签: javascript jquery ember.js