时间:2021-03-19 09:44:35 | 栏目:vue | 点击:次
本文实例为大家分享了vue-drawer-layout实现手势滑出菜单栏的具体代码,供大家参考,具体内容如下
安装
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>