0
のは、我々はこのような暴動のSPAがあるとしましょう:RiotJS 3:呼び出しでタグ機能
のindex.html:
<my-tag></my-tag>
<script type="riot/tag" src="my-tag.riot"></script>
<script>
//OK we need a compile() wrapper to access all tag instances
var tags;
riot.compile(function() {
tags = riot.mount('*');
});
</script>
私-tag.riot:
<my-tag>
<p>My tag</p>
<script>
myFunction(){
console.log('doing stuff...')
}
</script>
</my-tag>
IをmyFunction()をindex.htmlから呼び出すとします。
riot.compile(function() {
tags = riot.mount('*');
});
tags[0].myFunction();
実際には、タグ配列は、コンパイルの外に使用できません()のラッパー :理論的にはこのようなものである可能性があります。もちろん、コンパイル()の内側からmyFunction()を呼び出すことができます。
riot.compile(function() {
tags = riot.mount('*');
tags[0].myFunction();
});
しかし、私はそれが良いアプローチであるとは確信していません。では、タグ内関数にアクセスするにはどうすればよいでしょうか?前もって感謝します!
プランナーで同じ問題が発生しました: http://plnkr.co/2G3ReNBCpgCSgDZc1f9O –