vue-drawer-layout实现手势滑出菜单栏
程序员文章站
2022-04-25 17:00:23
...
安装
npm install vue-drawer-layout --save
main.js导入
import DrawerLayout from 'vue-drawer-layout'
Vue.use(DrawerLayout)
完整代码
<template>
<div class="box">
<vue-drawer-layout :drawer-width="230" ref="drawerLayout" @mask-click="closeMenu()">
<div class="drawer" slot="drawer">
<div>菜单栏</div>
</div>
<div class="content" slot="content">
<button type="primary" @click="openMenu()">打开菜单栏</button>
</div>
</vue-drawer-layout>
</div>
</template>
<script>
export default {
data() {
return {};
},
mounted() {},
methods: {
openMenu() {
this.$refs.drawerLayout.toggle();
},
closeMenu() {
this.$refs.drawerLayout.toggle(false);
},
},
};
</script>
<style lang="less" scoped>
.drawer {
width: 100%;
height: 100%;
background: #fff;
}
</style>