vue给元素添加指令_Vue指令动态模糊元素

vue给元素添加指令

v模糊 (v-blur)

Vue directive to blur an element dynamically. Useful to partially hide elements, use it with a spinner when content is not ready among other things.

Vue指令可动态模糊元素。 对于部分隐藏元素很有用,当内容还没准备好时,可以与微调器一起使用它。

安装 (Install)

$ npm install --save v-blur
$ yarn add v-blur

绑定值 (Binding value)

The binding value can be a Boolean or an Object. If a Boolean is provided, the directive uses default values for opacity, filter and transition. To use a custom configuration, an object with these attributes plus isBlurred (To determine when to apply these styles) can be provided.

绑定值可以是布尔值或对象。 如果提供了布尔值,则伪指令将不透明度过滤器过渡使用默认值。 要使用自定义配置,可以提供具有这些属性以及isBlurred (以确定何时应用这些样式)的对象。

绑定对象属性 (Binding object attributes)

optiondefaulttype
isBlurredfalseboolean
opacity0.5number
filter'blur(1.5px)'string
transition'all .2s linear'string
选项 默认 类型
isBlurred 布尔值
不透明 0.5
过滤 '模糊(1.5px)'
过渡 '所有.2s线性'

(Use)

import Vue from 'vue'
import vBlur from 'v-blur'

Vue.use(vBlur)
<script>
  export default {
      data () {
        return {
          isBlurred: true, // activate and deactivate blur directive example 1
          
          blurConfig: {
            isBlurred: false, // activate and deactivate blur directive example 2
            opacity: 0.3,
            filter: 'blur(1.2px)',
            transition: 'all .3s linear'
          }
        }
      }
    }
  };
</script>

<template>
  <!-- Example 1 using just a boolean (Uses default values) -->
  <div v-blur="isBlurred"></div>

  <!-- Example 2 using an object (Uses config values) -->
  <div v-blur="blurConfig"></div>
</template>

(Example)

v-blur-image-1

翻译自: https://vuejsexamples.com/vue-directive-to-blur-an-element-dynamically/

vue给元素添加指令

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值