riot.js tagの存在タイミング
on or one('mount',...) で図る。
codeMirrorのようなdocument.bodyに存在していなければフォーマットが崩れる場合、dom生成のタイミングは重要。
<script src="//gnjo.github.io/riot.js"></script>
<h1>dom exist check</h1>
<test></test>
<script type="text/plain" name="cheat-sheet">
this.one this.on this.off this.trigger:
update updated before-mount mount
before-unmount unmount
</script>
riot.tag(
'test'
,`<h3 id={x} onclick={click}>{message}</h3>`
, function(opts){
message='click me'
x='xxx'
console.log('constructer',document.querySelector('#xxx')) // not join body
this.one('mount',()=>{
console.log('mount-ed',document.querySelector('#xxx')) //slave the body
})
click=function(ev){
message = (document.querySelector('#xxx'))?'is':'not'
}
});
//finally one;
riot.mount('test');
Author And Source
この問題について(riot.js tagの存在タイミング), 我々は、より多くの情報をここで見つけました https://qiita.com/HadaGunjyo/items/d34f94f77ade53c26db4著者帰属:元の著者の情報は、元の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 .