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 🙏

© 2026 – Pkg Stats / Ryan Hefner

vue-directive-toolkit

v1.0.3

Published

A collection of useful Vue 3 custom directives

Readme

Vue Directive Toolkit

npm version license

一款轻量级的 Vue 3 自定义指令集合,提供开发中常用的 DOM 操作指令,支持 TypeScript,支持按需引入。

特性

  • 🎯 开箱即用 - 一键注册所有指令
  • 🧩 按需引入 - 支持 Tree Shaking,只打包用到的指令
  • 📦 TypeScript - 完整的类型定义
  • 🔧 灵活配置 - 支持自定义参数和修饰符

安装

npm install vue-directive-toolkit

使用

全局注册

import { createApp } from 'vue'
import App from './App.vue'
import VueDirectiveToolkit from 'vue-directive-toolkit'

const app = createApp(App)
app.use(VueDirectiveToolkit)
app.mount('#app')

按需引入

import { createApp } from 'vue';
import { vFocus, vDebounce } from 'vue-directive-toolkit';
import App from './App.vue';

const app = createApp(App);
app.directive('focus', vFocus);
app.directive('debounce', vDebounce);
app.mount('#app');

指令列表

  • v-focus - 自动聚焦指令
<template>
  <input v-focus placeholder="自动聚焦" />
</template>
  • v-debounce - 防抖指令
<template>
  <!-- 基础用法:click 事件防抖 300ms -->
  <button v-debounce:click="handleClick">点击</button>
  
  <!-- 自定义延迟:500ms -->
  <button v-debounce:click.500="handleClick">防抖 500ms</button>
  
  <!-- 输入防抖 -->
  <input v-debounce:input.300="handleInput" />
</template>
  • v-throttle - 节流指令
<template>
  <!-- 滚动节流 200ms -->
  <div v-throttle:scroll.200="handleScroll" class="scroll-container">
    滚动内容...
  </div>
  
  <!-- 窗口 resize 节流 -->
  <div v-throttle:resize.100="handleResize">自适应布局</div>
</template>
  • v-lazy - 图片懒加载指令
<template>
  <img v-lazy="imageUrl" alt="懒加载图片" />
</template>

<script setup>
const imageUrl = 'https://example.com/image.jpg';
</script>
  • v-click-outside - 点击元素外触发回调指令
<template>
  <div v-click-outside="closeDropdown" class="dropdown">
    点击外部关闭我
  </div>
</template>

<script setup>
const closeDropdown = () => {
  console.log('点击外部,关闭下拉');
};
</script>