1

在组件内部,如果需要,我很乐意使用下面的语法来加载其他组件:

<!-- Import example component -->
<link rel='ractive' href='internal-example.html' name='InternalExample'>

我的问题是,如何访问由Ractive Load在另一个组件中创建的示例组件实例?

重要的:

我可以定义主要组件的存储位置,我可以看到...anotherMainComponent.components.InternalExample但它似乎不是一个实例,因为我不能使用getset

相反,它似乎是要重用的“组件定义”(这对我来说很好)。

4

1 回答 1

1

您可以使用以下findComponent方法:

// assuming `ractive` is the top-level instance
// (i.e. `ractive = new MyComponent(...)`)
var internalExample = ractive.findComponent( 'InternalExample' );

ractive.findAllComponents是一个相关的方法 -文档herehere

于 2015-04-28T18:38:11.287 回答