Skip to content

Instantly share code, notes, and snippets.

@ayasuda
Created June 9, 2016 07:43
Show Gist options
  • Save ayasuda/8f784a88024b9f77b8d67281bad87c2f to your computer and use it in GitHub Desktop.
Save ayasuda/8f784a88024b9f77b8d67281bad87c2f to your computer and use it in GitHub Desktop.
クライアントサイドルーターの動き方
<!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