Riot.jsを始めてみた (2)
次はルーティングさせてみた。
ver3以降はrouteが外部ファイルとなったのでダウンロードして使う必要があるっぽい。
github.com
今回書いたコード
main.html
<html> <head> <title>Riot.js</title> <script src="./riot-master/riot+compiler.js"></script> <script src="./route-master/dist/route.js"></script> </head> <body> <layout></layout> <script type="riot/tag" src="main.tag"></script> <a href="#hoge">change</a> <script> riot.mount('layout'); route.start(); route('hoge', function(name) { riot.mount('main','sub'); }); </script> </body> </html>
main.tag
<layout> <main></main> </layout> <main> <h1>Hello World</h1> </main> <sub> <h1>Hello @kwnktks0515</h1> </sub>