如何访问 composed children?
How to access composed children?
我有一个组成元素列表:
<compose repeat.for="foo of someList" view-model="./bar" model.bind="foo">
现在,我想从父级调用特定 bar
视图模型上的函数。我该怎么做?
您可以在撰写标签中添加 view-model.ref
:
<compose repeat.for="foo of someList" view-model="./bar" model.bind="foo" view-model.ref="foo.barviewmodel">
您可以将 view-model.ref
替换为 compose.ref
。两者给出相同的结果。
并且在父级中,您可以像这样在 bar
视图模型上调用函数:
this.someList[2].barviewmodel.currentViewModel.action();
有效,但我不知道它是否是 public api。有关详细信息,请参阅 this issue
我有一个组成元素列表:
<compose repeat.for="foo of someList" view-model="./bar" model.bind="foo">
现在,我想从父级调用特定 bar
视图模型上的函数。我该怎么做?
您可以在撰写标签中添加 view-model.ref
:
<compose repeat.for="foo of someList" view-model="./bar" model.bind="foo" view-model.ref="foo.barviewmodel">
您可以将 view-model.ref
替换为 compose.ref
。两者给出相同的结果。
并且在父级中,您可以像这样在 bar
视图模型上调用函数:
this.someList[2].barviewmodel.currentViewModel.action();
有效,但我不知道它是否是 public api。有关详细信息,请参阅 this issue