vue移動(dòng)端時(shí)彈出側(cè)邊抽屜菜單效果
效果圖:
aside.vue:
<template> <div class="aside"> <div style=" height: 60px; background-color: #2e6baa; line-height: 60px; display: flex; align-items: center; justify-content: center; " > <img src="https://lj-common.oss-cn-chengdu.aliyuncs.com/vue.png" style="width: 30px; height: 30px" /> <span style=" font-size: 20px; font-weight: 600; color: white; margin-left: 10px; " >xxx平臺(tái)</span > </div> <perfect-scrollbar> <el-menu :default-active="$route.path" class="el-menu-vertical-demo" background-color="#017BC4" text-color="white" active-text-color="white" > <el-menu-item index="/page1" @click="$router.push({ path: '/page1' })"> <el-image src="https://lj-common.oss-cn-chengdu.aliyuncs.com/vue.png" style="width: 30px; height: 30px; margin-right: 5px" ></el-image> <span slot="title">page1</span> </el-menu-item ><el-menu-item index="/page2" @click="$router.push({ path: '/page2' })"> <el-image src="https://lj-common.oss-cn-chengdu.aliyuncs.com/vue.png" style="width: 30px; height: 30px; margin-right: 5px" ></el-image> <span slot="title">page2</span> </el-menu-item> </el-menu> </perfect-scrollbar> </div> </template> <script> export default { data() { return {}; }, created() {}, computed: {}, methods: {}, }; </script> <style lang='scss' scoped> .aside { height: 100vh; .ps { height: calc(100vh - 60px); //展開時(shí)寬度 .el-menu-vertical-demo:not(.el-menu--collapse) { width: 256px; } .el-menu { height: 100%; border: 0 !important; //垂直時(shí),去除右側(cè)白邊 } //item激活時(shí)的樣式 .el-menu-item.is-active { background-color: #1890ff !important; border-bottom: 0 !important; } } } </style>
控制抽屜顯隱:
<el-drawer :visible.sync="drawer" direction="ltr" :with-header="false" :size="256" > <vAside></vAside> </el-drawer>
<i class="el-icon-s-unfold hidden-sm-and-up" @click="collapseChange"></i>
<script> import vAside from "./aside.vue"; export default { name: "home", components: { vAside }, props: {}, data() { return { drawer: false, }; }, methods: { // 切換折疊狀態(tài) collapseChange() { this.drawer = !this.drawer; }, }, }; </script>
由于上面使用了hidden-sm-and-up樣式,該樣式需要在main.js中引入display.css,如下:
import 'element-ui/lib/theme-chalk/display.css';
更多樣式參考:
Vue中使用vue2-perfect-scrollbar制作滾動(dòng)條
element-ui 實(shí)現(xiàn)響應(yīng)式導(dǎo)航欄的示例代碼
到此這篇關(guān)于vue移動(dòng)端時(shí)彈出側(cè)邊抽屜菜單的文章就介紹到這了,更多相關(guān)vue彈出側(cè)邊抽屜菜單內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
VUE:vuex 用戶登錄信息的數(shù)據(jù)寫入與獲取方式
今天小編就為大家分享一篇VUE:vuex 用戶登錄信息的數(shù)據(jù)寫入與獲取方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-11-11Vue如何循環(huán)提取對(duì)象數(shù)組中的值
這篇文章主要介紹了Vue如何循環(huán)提取對(duì)象數(shù)組中的值,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-11-11Vue?ECharts實(shí)現(xiàn)機(jī)艙座位選擇展示功能代碼詳解
這篇文章主要介紹了Vue?ECharts實(shí)現(xiàn)機(jī)艙座位選擇展示,本文給大家分享一段簡(jiǎn)短的代碼通過效果圖展示給大家介紹的非常明白,需要的朋友可以參考下2022-05-05一文詳解vue各種權(quán)限控制與管理實(shí)現(xiàn)思路
這篇文章主要為大家介紹了vue各種權(quán)限控制與管理的實(shí)現(xiàn)思路詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-03-03vue動(dòng)態(tài)綁定ref(使用變量)以及獲取方式
這篇文章主要介紹了vue動(dòng)態(tài)綁定ref(使用變量)以及獲取方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-08-08vue利用指令實(shí)現(xiàn)快速設(shè)置元素的高度
在項(xiàng)目中經(jīng)常有需要將列表的高度設(shè)置成剩余可視區(qū)域的高度,本文主要來和大家介紹一下如何通過指令和css變量的方式快速設(shè)置列表高度,希望對(duì)大家有所幫助2024-03-03vue3中的watch和watchEffect實(shí)例詳解
watch和watchEffect都是監(jiān)聽器,但在寫法和使用上有所區(qū)別,下面這篇文章主要給大家介紹了關(guān)于vue3中watch和watchEffect的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-05-0515分鐘學(xué)會(huì)vue項(xiàng)目改造成SSR(小白教程)
這篇文章主要介紹了15分鐘學(xué)會(huì)vue項(xiàng)目改造成SSR(小白教程),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-12-12