Created
June 9, 2016 07:43
-
-
Save ayasuda/8f784a88024b9f77b8d67281bad87c2f to your computer and use it in GitHub Desktop.
クライアントサイドルーターの動き方
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<title>page.js の動き方</title> | |
<meta charset="UTF-8"> | |
</head> | |
<body> | |
<nav> | |
<ul> | |
<li><a href="/">メイン</a></li> | |
<li><a href="/hoge">ページ1</a></li> | |
<li><a href="/fuga">ページ2</a></li> | |
</ul> | |
</nav> | |
<article id="result">メインページです。</article> | |
</body> | |
<script src="https://cdn.rawgit.com/visionmedia/page.js/master/page.js"></script> | |
<script> | |
var el = document.getElementById('result'); | |
page('/', function() { el.innerHTML = 'メインページです。'; }); | |
page('/hoge', function() { el.innerHTML = 'ページ1です。'; }); | |
page('/fuga', function() { el.innerHTML = 'ページ2です。'; }); | |
page(); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment