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

tq-fv

v1.0.1

Published

vue表单验证指令

Downloads

1

Readme

指令

安装

npm install tq-fv

使用

import Vue from 'vue'
import Fv from 'tq-fv'

const fv = new Fv({
  inputFailedClass: 'some class name',
  msgFailedClass: 'some class name'
})

Vue.use(fv)

表单验证 $fv

默认class名

  • fv-input-fail 验证失败时加在input上的class
  • fv-msg-fail 验证失败时添加在错误信息显示标签上的class

fv-check

修饰符

|修饰符|说明| |-----|----| |required | 必填项 | |number| 数字 | | email | 邮箱 | | mobile | 手机 | | identity | 身份证 | | postcode | 邮编 |

参数 {Object}

  • reg {RegExp | RegExp Array} 要验证的正则表达式
  • title {String} 被验证项的标题,用来显示错误提示信息
  • allowEmpty {Boolean} 是否允许为空 默认false
  • max {Number} 最大长度
  • min {Number} 最小长度
  • rules {Array} 修饰符数组,和修饰符效果相同

tip

  • 指令必须写在表单输入元素上,如input,textarea等
  • 输入元素必须有id属性

fv-msg

参数 {String}

  • 绑定的input的id

实例

属性

  • this.$fv.errors {Array} 验证不通过的列表

方法

  • this.$fv.checkAll(callback) 手动出发验证
    • callback {function} 回调函数
      • errors {Array} 回调函数的入参,返回未通过检查的条目

例1

<input v-fv-check="{rules: ['required'], title:'用户名', min: 2, max: 5}" id="searchInput" type="text" placeholder="请输入关键词"/>
<span v-fv-msg="'searchInput'"></span>