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 🙏

© 2025 – Pkg Stats / Ryan Hefner

vue-input-directive

v1.1.5

Published

vue limit input directive,validate input

Downloads

23

Readme

codepen地址

https://codepen.io/maiyaoqiang/pen/rNmVNXa?editors=1010

用法

已兼容vue3.0

npm install vue-input-directive --save
import Vue from 'vue'
import inputValidate from 'vue-input-directive'
Vue.use(inputValidate)

1.d-input-max

输入数字限制最大值

 <el-input v-d-input-max="99.99" v-model="value"></el-input>

2.d-input-int

只能输入正整数

 <el-input v-d-input-int v-model="value"></el-input>

3.d-input-point2

最多只能输入两位小数

 <el-input v-d-input-point2 v-model="value"></el-input>

4.d-input-en

只能输入英文

 <el-input v-d-input-en v-model="value"></el-input>

5.d-input-regexp

限制正则内容,输入时若正则部分匹配,则把匹配的部分留下,其余清空 实际上上面4种除了输入两位小数以外其他3个都可以用正则替代

<!-- 限制不能输入中文 -->
 <el-input v-d-input-regexp="/((?![\u4E00-\u9FA5]).)*/" v-model="value"></el-input>
<!-- 限制仅可输入数字字母 -->
 <el-input v-d-input-regexp="/[0-9A-Za-z]*/" v-model="value"></el-input>

6.混合使用

<!-- 限制输入两位小数 最大可输入99.99 -->
 <el-input 
  v-d-input-point2
  v-d-input-max="99.99"
  v-model="value"></el-input>

7.自定义正则

只能输入数字和字母和中文

import Vue from 'vue'
import {DInitFun} from 'vue-input-directive'
// 只能输入数字和字母
Vue.directive(
  'd-input-num-en',
  DInitFun((ele, binding) => {
      let value = ele.value + ''
      const reg = /[a-zA-Z0-9\u4E00-\u9FA5]*/
      const matchRes = value.match(reg)
      if (matchRes) {
        value = matchRes[0]
      } else {
        value = ''
      }
      ele.value = value
  })
)