vue-drawer-layout实现手势滑出菜单栏

2020-09-19 13:51:31 浏览数 (1)

文档链接地址

安装

代码语言: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>

0 人点赞