riot.js global mixin
trigger は長いのでemitに変更してみる。
riot.mixin({emit:function(){return this.trigger.apply(this,Array.from(arguments)) } });
確認
<script src="//gnjo.github.io/riot.js"></script>
<t></t>
<t2></t2>
riot.mixin({emit:function(){return this.trigger.apply(this,Array.from(arguments)) } })
;
riot.tag('t',false,function(opts){
this.on('xyzed',(x)=>{console.log('xyzed',x)})
this.emit('xyzed','emit');
this.trigger('xyzed','trigger')
});
riot.tag('t2',false,function(opts){
this.on('xyzed',(x)=>{console.log('xyzed',x)})
this.emit('xyzed','t2 emit');
this.trigger('xyzed','t2 trigger')
});
riot.mount('*')
Author And Source
この問題について(riot.js global mixin), 我々は、より多くの情報をここで見つけました https://qiita.com/HadaGunjyo/items/2a4a6676bc5dac569ca5著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .