文档链接地址
安装
代码语言:javascript复制npm install vue-drawer-layout --save
main.js导入
代码语言:javascript复制import DrawerLayout from 'vue-drawer-layout'
Vue.use(DrawerLayout)
完整代码
代码语言:javascript复制<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>