javascript实例:路由的跳转
<!doctype html> <html > <body> <a href="#/home">首页</a> <a href="#/course">课程</a> <div ></div> <script> window.onhashchange = function(){ console.log(location.hash); switch (location.hash) { case '#/home': document.getElementById('app').innerHTML = '<h2>我是首页</h2>'; break; case '#/course': document.getElementById('app').innerHTML = '<h2>我是课程</h2>'; break; default: // statements_def break; } } </script> </body> </html>