简体   繁体   English

如何从DOM元素获取Aurelia ViewModel

[英]How to get the Aurelia ViewModel from a DOM Element

I remember reading some days ago about a method to get the ViewModel of a component let's say, starting from the DOM node. 我记得几天前读过关于从DOM节点开始获取组件的ViewModel的方法。

I guess those elements are those that have a au-target class on them (added by Aurelia). 我猜这些元素就是那些具有au-target类的元素(由Aurelia添加)。

I've searched on google / documentation but did not manage to find anything. 我搜索了谷歌/文档,但没有找到任何东西。

So, how can I get the ViewModel of that element? 那么,我怎样才能获得该元素的ViewModel?

我相信你在寻找这个:

this.element.au.controller.viewModel

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM