LoginSignup
0
0

More than 5 years have passed since last update.

riot.js click demo

Last updated at Posted at 2018-04-09

riot.tag(...)は~将来的にサポートされないらしいが、誤訳~一部機能制限があるが、short coding用として便利。

<script src="//gnjo.github.io/riot.js"></script>
<h1>Acme community</h1>
<test></test>
riot.tag(
 'test'
 ,`<h3 class={cls} onclick={click}>{message}</h3>`
 ,`.red{color:red}`
 , function(opts){
   message='helloxyz'
   click=function(ev){ cls='red' }
})
;
riot.mount('*');//finally one

clickするごとにカラーを変更

<script src="//gnjo.github.io/riot.js"></script>
<script src="//gnjo.github.io/colorNames.js"></script>
<h1>Acme community</h1>
<test></test>

riot.tag(
 'test'
 ,`<link gvar={gvar}><h3 onclick={click} style="color:{c};cursor:pointer">{message}</h3>`
 , function(opts){
   gvar={num:0,cArray:opts.cArray}
   message='click me'
   console.log(this);
   //style need "" //http://riotjs.com/api/#manual-construction
   click=function(ev){
    c='#'+gvar.cArray[gvar.num++].hex
   }
});

//finally one;
window.cArray=Object.keys(window.colorNames).map((d)=>{return{name:d,hex:window.colorNames[d]};});
riot.mount('test',{cArray:window.cArray});

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0