[英]Riot.js: How to catch an event in sub tag with Observable pattern?
I want to be able to create an reuseable subtag: 我希望能够创建可重复使用的子标签:
<tag>
<subtag id=subtag></subtag>
</tag>
Therefor I would like to use the observable pattern to communicate with the sub tag: 因此,我想使用可观察的模式与sub标签通信:
var self = this
subtag = riot.mount('#subtag')[0]
subtag.on('clicked', function(){
console.log('subtag has been clicked)
})
The code does not work since was already mounted. 由于已安装该代码,因此无法正常工作。 If I place the subtag outside the tag, it does however work.
如果我将子标签放置在标签之外,则它可以工作。 How to catch an event using the sub tag notation?
如何使用子标签符号捕获事件?
从riot.js v2.0.13开始,所有命名的子标签都可以使用self.<id>
进行访问,有关详细信息,请参见: 如何访问riot.js中的子元素
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.