npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fastvue/directive

v1.2.0

Published

vue的常用指令集

Downloads

2

Readme

@fastvue/directive

vue2 的常用指令集合

安装

使用 npm
npm install @fastvue/directive --save
使用 yarn
yarn add @fastvue/directive
使用 pnpm
pnpm add @fastvue/directive

使用

import Vue from "vue";
import Directives from "@fastvue/directive";
Vue.use(Directives);

例子

按钮点击防抖

<template>
  // 不传时间默认1000ms
  <button v-debounce="debounceClick">防抖按钮</button>
  <button v-debounce:2000="debounceClick">防抖按钮</button>
</template>

<script>
export default {
  methods: {
    debounceClick () {
      console.log('触发一次')
    }
  }
}
</script>

一键复制文本

<template>
  <button v-copy="copyConfig">复制</button>
</template>

<script> export default {
    data() {
      return {
        copyConfig: {
          text: '复制的内容XXX', //复制的内容
          onSuccess: ()=> {}  //复制成功后的回调
        }
      }
    },
  }
</script>

图片懒加载

将组件内 标签的 src 换成 v-LazyLoad

<img v-LazyLoad="xxx.jpg" />

添加水印

使用,设置水印文案,颜色,字体大小即可

<template>
  <div v-waterMarker="{text:'dayu',textColor:'#ddd'}"></div>
</template>

元素拖拽

使用: 在 Dom 上加上 v-draggable 即可

<template>
  <div v-draggable></div>
</template>

限制输入框特殊字符输入

将需要校验的输入框加上 v-emoji 即可

<template>
  <input type="text" v-model="note" v-emoji />
</template>

输入框自动获取焦点

将需要校验的输入框加上 v-focus 即可

<template>
  <input type="text" v-model="note" v-focus />
</template>

判断点击事件是否发生在指定的元素外部

将需要校验的元素加上 v-clickOutside 即可

<template>
  <div v-clickOutside="handleClickOutside"></div>
</template>

用于禁用点击事件

将需要校验的元素加上 v-disableClick 即可

<template>
  <div v-disableClick="isDisabled"></div>
</template>

无限滚动加载

这个指令用于实现无限滚动加载。它接受一个函数作为参数,该函数将在滚动到页面底部时调用。

<template>
  <div v-infinite-scroll="loadMoreData" style="height: 500px; overflow-y: scroll;">  
    <div v-for="item in items" :key="item.id">{{ item.name }}</div>  
  </div>
</template>