国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

vue的hash值原理也是table切換實例代碼

瀏覽:9日期:2022-10-19 11:40:31

我希望大家敲一遍

<!DOCTYPE html><html><head><meta charset='utf-8'><title></title><style>.pages>div{display: none;}</style></head><body><p><a href='http://www.intensediesel.com/bcjs/10507.html#/' rel='external nofollow' >aaa</a><a href='http://www.intensediesel.com/bcjs/10507.html#/about' rel='external nofollow' >bbb</a><a href='http://www.intensediesel.com/bcjs/10507.html#/user' rel='external nofollow' >cccc</a></p><div class='pages'><div id='home'>首頁</div><div id='about'>關于我的頁面</div><div class='user'>用戶中心</div></div></body><script type='text/javascript'>//hash 和頁面一一對應起來//router 配置var router = [{path:'/',component:document.getElementById('home')},{path:'/about',component:document.getElementById('about')},{path:'/user',component:document.querySelector('.user')},]// 默認hashwindow.location.hash = '#/';// 默認頁面var currentView = router[0].component;currentView.style.display='block';window.onhashchange=()=>{//通過判斷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';//重新設置當前顯示的頁面是哪個divcurrentView = item.component;}})}</script></html>

vue的hash值原理也是table切換實例代碼vue的hash值原理也是table切換實例代碼vue的hash值原理也是table切換實例代碼

到此這篇關于vue的hash值原理也是table切換的文章就介紹到這了,更多相關vue hash原理內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Vue
相關文章:
主站蜘蛛池模板: 增城市| 宁安市| 读书| 安庆市| 兴隆县| 湖州市| 溧阳市| 台东县| 成安县| 秦安县| 隆昌县| 来宾市| 苍溪县| 佛山市| 自贡市| 舟山市| 东乡| 沾益县| 泰兴市| 乌苏市| 龙南县| 康平县| 获嘉县| 旺苍县| 凤山县| 永城市| 双桥区| 长岛县| 景东| 宁夏| 盐亭县| 南昌县| 文水县| 平顺县| 本溪| 加查县| 景宁| 常德市| 吉木萨尔县| 嘉定区| 商城县|