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

vue3-directives-bens

v1.0.1

Published

这是一个基于Vue3&TS&elementui-Plus的自定义指令库与hooks库

Downloads

1

Readme

这是一个基于 Vue3&TS&elementui-Plus 的自定义指令库与 hooks 库

安装方式:

npm install vue3-directives-bens -D
yarn add vue3-directives-bens -D
pnpm install vue3-directives-bens -D

使用方式:

import { directives } from "vue3-directives-bens";
app.use(directives);

功能

v-copy 一键复制

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

v-debounce 防抖

<template>
  <el-button v-debounce="{ input: handleInput, blur: handleBlur, click: handleClick, change: handleChange, clear: handleClear }">
    防抖
  </el-button>
</template>

v-throttle 节流

<template>
   <div>
     <el-button type="primary" v-throttle="throttleClick">节流按钮 (每隔1S秒后执行)</el-button>
   </div>
</template>
<script setup lang="ts">
  import { ElMessage } from "element-plus";
  const throttleClick = () => {
      ElMessage.success("我是节流按钮触发的事件");
  };
</script>

v-disable-button 禁用按钮

点击后需要禁用多久,才能再次点击

<template>
   <button v-disable-button:delay="1000">Click me</button> <!-- 延迟时间为 1000ms -->
</template>

v-draggable 拖拽

示例

<template>
  <div class="content-box">
      <span class="text">拖拽指令</span>
      <div v-draggable class="drag-box cursor-move">我可以拖拽的</div>
 </div>
</template>
<style lang="scss" scoped>
.content-box {
position: relative;//required
width: 500px;
height: 500px;
border: 1px solid #ccc;
.drag-box {
position: absolute;//required
width: 100px;
height: 100px;
background-color: #ccc;
    }
}
</style>

v-emoji 输入内容的限制

比如不能输入表情和特殊字符,只能输入数字或字母等。 v-emoji 或 v-emoji="'!@$%^&*()_+-=[]{}|;:,.<>?/'"

<template>
   <div>
     <input type="text" v-emoji="'!@$%^&*()_+-=[]{}|;:,.<>?/'">
   </div>
</template>

v-longpress 长按事件

<template>
  <div class="card content-box">
    <span class="text">长按指令</span>
    <el-button type="primary" v-longpress="longpress">长按2秒触发事件</el-button>
  </div>
</template>

<script setup lang="ts">
 import { ElMessage } from "element-plus";
 const longpress = () => {
 ElMessage.success("长按事件触发成功");
};
</script>

v-permission 权限

<template>
  <div>
    <p v-permission="{ value: '1', array: ['1', '2', '3', '4'] }">
      Permission '1'
    </p>
    <p v-permission="{ value: '5', array: ['1', '2', '3', '4'] }">
      Permission '5'
    </p>
    <p v-permission="{ value: ['2', '3'], array: ['1', '2', '3', '4'] }">
      Permission '2' or '3'
    </p>
  </div>
</template>

v-spare 备用图片

// 监听img的error事件
// img加载错误后触发error事件,检验备用地址是否有效
// 如果备用有效,将备用地址赋值给img的src
 <img :src="imgScr" v-spare="spareImg" />

v-water-marker 水印

<div
  style="width: 100%"
  v-water-marker="{ text: 'bennettliang', font: '16px Microsoft JhengHei', textColor: '#000' }"
></div>

更多指令待开发