Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue 实现drawer抽屉效果 #57

Open
PleaseStartYourPerformance opened this issue Jan 6, 2022 · 0 comments
Open

Vue 实现drawer抽屉效果 #57

PleaseStartYourPerformance opened this issue Jan 6, 2022 · 0 comments

Comments

@PleaseStartYourPerformance
Copy link
Owner

PleaseStartYourPerformance commented Jan 6, 2022

超级简单---直接上代码

html

      <button @click="handleClick">点我触发drawer</button>
      <transition name="fade">
        <div class="chart-efficiecy-report-drawer-background" v-show="drawerVisible" @click="handlerDrawerClick" />
      </transition>
      <transition name="into">
        <div class="chart-efficiecy-report-drawer-content" v-show="drawerVisible">
          <efficiecy-all-focus/>
        </div>
      </transition>

js

  public drawerVisible = false
  public handleClick(){
    this.drawerVisible = true;
  }
  public handlerDrawerClick(){
    this.drawerVisible = false;
  }

css

<style lang="scss" scoped>
  .chart-efficiecy-report{
    &-drawer-background{
      position: fixed;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      background: rgba(0, 0, 0, 0.6);
      z-index: 1000;
    }
    &-drawer-content{
      position: fixed;
      width: 380px;
      height: 100%;
      top: 0;
      right: 0;
      background: #fff;
      z-index: 1002;
      transition: right .2s;
    }
  }
  .fade-enter-active, .fade-leave-active {
    transition: opacity .4s
  }
  .fade-enter, .fade-leave-active {
    opacity: 0
  }
  .into-enter-active, .into-leave-active {
    right: 0;
  }
  .into-enter, .into-leave-active {
    right: -380px;
  }
</style>

效果:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant