vue 计算文件hash值_vue的hash值原理,也是table切换。
.pages>div{display: none;}
aaa
bbb
cccc
首頁關于我的頁面用戶中心//hash 和頁面一一對應起來
//router 配置
var router = [
{path:"/",component:document.getElementById("home")},
{path:"/about",component:document.getElementById("about")},
{path:"/user",component:document.querySelector(".user")},
]
// 默認hash
window.location.hash = "#/";
// 默認頁面
var currentView = router[0].component;
currentView.style.display="block";
window.οnhashchange=()=>{
//通過判斷hash切換div頁面
console.log(location.hash);
//獲取hash值,不要井號
var hash = location.hash.slice(1);
router.forEach(item=>{
if(item.path==hash){
//先隱藏之前顯示的頁面
currentView.style.display = "none";
// 顯示對應的組件
item.component.style.display = "block";
//重新設置當前顯示的頁面是哪個div
currentView = item.component;
}
})
}
總結
以上是生活随笔為你收集整理的vue 计算文件hash值_vue的hash值原理,也是table切换。的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 20天掌握C语言,C语言零基础到项目实战
- 下一篇: html5倒计时秒杀怎么做,vue 设