javascript 路由跳转
2020-12-13 14:23
标签:OLE UNC nbsp ext java switch ack text 跳转 javascript 路由跳转 标签:OLE UNC nbsp ext java switch ack text 跳转 原文地址:https://www.cnblogs.com/whileke/p/11560183.htmlDOCTYPE html>
html lang="en">
head>
meta charset="UTF-8">
title>Titletitle>
head>
body>
a href="#/home" >这里a>
a href="#/lon">白天a>
div id="app">div>
script type="text/javascript">
// console.log(location)
//路由的跳转
//onhashchange是window的一个方法
window.onhashchange=function () {
console.log(111);
console.log(location.hash); //这里可以获取当前的路由信息
switch(location.hash) {
case ‘#/home‘:
document.getElementById(‘app‘).innerHTML=‘
课程
‘;
break;
case ‘#/lon‘:
document.getElementById(‘app‘).innerHTML = ‘价钱
‘;
break;
}
}
script>
body>
html>
下一篇:初尝Web API《转》