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

shawbs-form

v1.0.2

Published

A vue form component

Downloads

3

Readme

Vue表单组件

这是一个十分简易的表单组件,它只用于进行表单验证,而几乎没有任何样式(除了错误提示以外),你可以把它用于任何设备稿中的表单。

  • 支持:Vue2.x

安装

npm install shawbs-form - S

使用

import ShawbsForm from 'shawbs-form'
import 'shawbs-form/lib/index.css'


Vue.use(ShawbsForm)

Form

| props | 说明 | 是否必填 | 值 | | :-----| ----: | :----: | :----: | | model | 一个object对象,包含了表单中的各个属性 | 是 | Object | rules | 表单检验规则,支持require/reg/handle等3种方式 | 是 | Object

FormItem

| props | 说明 | 是否必填 | 值 | | :-----| ----: | :----: | :----: | | prop | 表单中的某个属性,它必须在Form的model中存在 | 是 | String

Form 方法

| 名 | 说明 | | :-----| ----: | | check | 验证表单是否有效,参数为Boolean,true是有效,false是无效 |

EXAMPLE

alt text

Code


<template>
    <div id="app">
        <h3>Example</h3>
        <shawbs-form :model="formData" :rules="rules" ref="form">
            <div>用户名</div>
            <shawbs-form-item prop="username">
                <input type="text" v-model="formData.username">
            </shawbs-form-item>
            <div>密码</div>
            <shawbs-form-item prop="password">
                <input type="text" v-model="formData.password">
            </shawbs-form-item>
            <div>确认密码</div>
            <shawbs-form-item prop="password2">
                <input type="text" v-model="formData.password2">
            </shawbs-form-item>
        </shawbs-form>

        <p>
            <button @click="submit">提交</button>
        </p>
    </div>
</template>

<script>
    export default {
        data(){
            const handle = (e) => {
                if(e == ''){
                    return '确认密码不能为空'
                }
                if(e != this.formData.password){
                    return '两次密码不一致'
                }
            }
            return {
                formData: {
                    username: '',
                    password: '',
                    password2: ''
                },
                rules: {
                    username: [{require: true,message: '用户名不能为空'}],
                    password: [{require: true,message: '密码不能为空'},{reg: /\w{6,8}$/, message: '密码无效'}],
                    password2: [{handle: handle}]
                }
            }
        },
        methods:{
            submit(){
                this.$refs.form.check(valid => {
                    console.log(valid)
                })
            }
        }
    }
</script>

<style lang="less" scoped>

</style>