溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

vue2+el-menu實(shí)現(xiàn)路由跳轉(zhuǎn)及當(dāng)前項(xiàng)的設(shè)置方法實(shí)例

發(fā)布時(shí)間:2020-08-22 16:48:18 來(lái)源:腳本之家 閱讀:1337 作者:iulyf 欄目:web開(kāi)發(fā)

Vue.js 是什么

Vue.js (讀音 /vjuː/,類(lèi)似于 view) 是一套構(gòu)建用戶界面的漸進(jìn)式框架。與其他重量級(jí)框架不同的是,Vue 采用自底向上增量開(kāi)發(fā)的設(shè)計(jì)。Vue 的核心庫(kù)只關(guān)注視圖層,它不僅易于上手,還便于與第三方庫(kù)或既有項(xiàng)目整合。另一方面,當(dāng)與單文件組件和 Vue 生態(tài)系統(tǒng)支持的庫(kù)結(jié)合使用時(shí),Vue 也完全能夠?yàn)閺?fù)雜的單頁(yè)應(yīng)用程序提供驅(qū)動(dòng)。

好了,下面通過(guò)本文給大家介紹vue2+el-menu實(shí)現(xiàn)路由跳轉(zhuǎn)及當(dāng)前項(xiàng)的設(shè)置方法,具體內(nèi)容如下所示:

<span  deep="5"><el-menu router :default-active="$route.path" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" theme="dark"> 
 <el-submenu index="1"> 
  <template slot="title"> 
   <i class="el-icon-location"></i> 
   <span>用戶信息</span> 
  </template> 
  <el-menu-item-group> 
   <el-menu-item index="/user/account">賬號(hào)信息</el-menu-item> 
   <el-menu-item index="/user/password">修改密碼</el-menu-item> 
 </el-submenu> 
 <el-submenu index="2"> 
   <template slot="title"> 
   <i class="el-icon-location"></i> 
   <span>公司信息</span> 
  </template> 
  <el-menu-item-group> 
   <el-menu-item index="/company/userManager">用戶管理</el-menu-item> 
   <el-menu-item index="/company/editUser">添加/編輯用戶</el-menu-item> 
  </el-menu-item-group> 
  </el-submenu> 
</el-menu></span> 

1.要實(shí)現(xiàn)路由跳轉(zhuǎn),先要在el-menu標(biāo)簽上添加router屬性,然后只要在每個(gè)el-menu-item標(biāo)簽內(nèi)的index屬性設(shè)置一下url即可實(shí)現(xiàn)點(diǎn)擊el-menu-item實(shí)現(xiàn)路由跳轉(zhuǎn)。

2.導(dǎo)航當(dāng)前項(xiàng),在el-menu標(biāo)簽中綁定  :default-active="$route.path",注意是綁定屬性,不要忘了加“:”,當(dāng)$route.path等于el-menu-item標(biāo)簽中的index屬性值時(shí)則該item為當(dāng)前項(xiàng)。

總結(jié)

以上所述是小編給大家介紹的vue2+el-menu實(shí)現(xiàn)路由跳轉(zhuǎn)及當(dāng)前項(xiàng)的設(shè)置方法實(shí)例,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)億速云網(wǎng)站的支持!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI