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

chem-form

v1.0.4

Published

使用 json 的方式便捷开发 form

Downloads

36

Readme

chem-form

使用 json 的方式便捷开发 form

安装

npm install chem-form
# or
yarn add chem-form

为什么

Vue.js + Element-ui 的组合加快了我们开发中台系统的速度,但是开发中发现存在大量的重复的操作,根据业内比较 🔥 的 scheme 的方式配置表单的方式,对其进行二次开发,加速实际开发速度。

如何使用

// main.js
import chemForm from "chem-form"
Vue.use(chemForm)

// common.vue
<template>
  <chem-form v-model="formData" :scheme="formConfig"></chem-form>
</template>

<script lang="ts">
  import { Vue, Component } from "vue-property-decorator";
  @Component
  export default class extends Vue {
    formData:Record<string, any> = {}
    formConfig = {
      DEBUG: true,
      items: [
        { prop: "name", label: "姓名" },
        { prop: "age", label: "年龄", "x-component": "number"},
        // ... add other form config
      ]
    }
  }
</script>

form Prop

| Name | Description | Type | | :------ | :---------- | :------ | | v-model | 表单数据 | { } | | scheme | 表单配置 | | | auth | 表单权限 | Array |

scheme

| Name | Description | params | | -------- | ---------------------------------------------------------------------- | ----------------------------------------------- | | DEBUG | 开启调试模式 | Boolean | | layout | 展示的形态 type 为展示类型, span 为表格模式下每个 form-item 占的大小 | { type: "default / inline / table", span: 8 } | | onlyRead | 是否为只读模式 | Boolean | | attrs | 扩充属性 element-ui 中 form 自带的属性 | Object | | items | 表单要展示的内容配置 | 参照 form-item props 配置 |

form methods

| Name | Description | callback | params | | :------------ | :--------------- | :---------------- | :----------------------------- | | resetForm | 重置表单 | - | - | | validateForm | 校验表单 | Promise | - | | clearValidate | 清空校验 | - | propName?: string | string[] | | setItem | 设置某字段的值 | - | propName: string, value: any | | getItemRef | 获取某字段 Ref | Vue | propName: string | | getFormModel | 获取所有表单数据 | Object | removeNull:boolean | | submit | 表单提交 | Function(model) | - |

form-item props

| Name | 说明 | 类型 | 默认值 | | ------------ | ----------------------------------------------------------------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | prop | 绑定的值(对应后端字段) | string | 必填 | | label | 页面中显示的名称 | string | 必填 | | isRender | 是否显示 | boolean | Function | true | | required | 是否进行校验 | boolean | false | | rules | 校验规则 | Array | [{ required: true, message: "label 为必填项"}] | | description | 对字段填写的提示信息 | string | VNode | null | | slot | 插槽的名字 - 该字段使用插槽内容展示 | string | null | | x-component | 自带的组件名字 | string | input (input / number / select / radio / checkbox / switch /slider / timePicker/ datePicker/ rate / upload ) | | attrs | 扩展属性,element-ui 中自带的的属性 | Record<string, any> | {} | | listeners | 扩展监听器,element-ui 该组件自带的监听器 | Record<string, Function> | {} | | source | 源数据,radio,select,checkbox 用来展示的数据 | { labelKey: string, valueKey: string, data: any[] | Function } | radio / checkbox / select 为必填项 | | colSpan | 表格模式下 form-item 占的大小 - 参照饿了么组件 el-col 中的 span 字段 | number | 8 | | supportEntry | 表格模式下该字段是否支持 | boolean | input / number / select 默认是 true | | |