vue中实现模态框弹出框动画(旋转弹出)

279 阅读1分钟

vue模态框弹窗动画

沃达尔 (Vodal)
A Nice vue modal with animations.

带有动画的尼斯vue模态。
安装

npm i -S vodal

用法

<template>
  <div class="home">
    <button @click="togglebox">点击弹出</button>
    <vodal :show="show" animation="rotate" @hide="show = false">
      <div>A vue modal with animations.</div>
    </vodal>
  </div>
</template>

<script>
import Vodal from "vodal";
export default {
  name: "name",
  components: {
    Vodal,
  },
  data() {
    return {
      show: false,
    };
  },
  methods: {
    togglebox: function () {
      this.show = true;
    },
  },
};
</script>
<style lang="scss" scoped>
// include animation styles
@import "../../node_modules/vodal/common.css";
@import "../../node_modules/vodal/rotate.css";
</style>

效果
在这里插入图片描述

道具 (Props )

PropertyTypeDefaultDescription
widthnumber400width of dialog
heightnumber240height of dialog
measurestringpxmeasure of width and height
showboolfalsewhether to show dialog
maskbooltruewhether to show mask
closeButtonbooltruewhether to show close button
closeOnEscboolfalsewhether close dialog when esc pressed
closeOnClickMaskbooltruewhether close dialog when mask clicked
animationstringzoomanimation type
durationnumber300animation duration
classNamestring/className for the container
customStylesobject/custom dialog styles
customMaskStylesobject/custom mask styles
属性类型默认描述
宽度400对话宽度
高度240对话高度
测量像素宽度和高度的度量
表演布尔是否显示对话框
面具布尔真正是否戴面具
closeButton布尔真正是否显示关闭按钮
closeOnEsc布尔按下esc时是否关闭对话框
closeOnClickMask布尔真正单击蒙版时是否关闭对话框
动画放大动画类型
持续时间300动画时长
班级名称/容器的className
customStyles目的/自定义对话框样式
customMaskStyles目的/自定义蒙版样式

事件 (Event)

NameDescription
hidetriggers when dialog will hide
clickMasktriggers when mask clicked
名称描述
隐藏对话框隐藏时触发
clickMask单击蒙版时触发

动画类型 (Animation Types)

  • zoom

    放大

  • fade

    褪色

  • flip

    翻转

  • door

  • rotate

    旋转

  • slideUp

    向上滑动

  • slideDown

    滑下

  • slideLeft

    向左滑动

  • slideRight

    向右滑动