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

filter-form-element-plus

v1.0.0

Published

基于element-plus二次开发的表单组件,旨在方便vue开发者迅速搭建表单模块,集中处理数据,实现这一切仅需一个对象

Downloads

5

Readme

filter-form

简单介绍

实际项目开发中会经常搭建 form,重复搭建,耗时耗力,开发一个库来重复使用,快速搭建一些常见的表单

目前支持组件

cascader input select select-v2 datePicker timePicker radio

后续会加入更多组件

使用方法

本示例为最简单的使用方法

import FilterForm from 'filter-form-element-plus'
import { type IForm, type IFormConfigurationItems } from 'filter-form-element-plus' // js无需导入

准备好数据对象,和配置对象

数据对象

const formData: IForm = {
  data1: '',
  data2: ''
}

配置对象

const formConfig: IFormConfigurationItems = {
  elForm: {
    // element-plus[后面所有的配置项无特殊声明均为element-plus,不在赘述]form的所有属性
  },
  typeSetting: [
    [
      {
        vModel: 'data1', // 绑定值,需要与数据对象中的元素对应
        component: 'select', // 组件的类型
        col?: {}, // 可选,默认占满一行 适用col所有属性
        elFormItem?: {
          slotScope?:[
            { // 若您想使用插槽,则需使用该字段,适用el-form-item所有插槽
            slotName:'label',
            render: () => h()
          }
          ]
        }, // 可选,适用el-form-item的所有属性
        customClassName?: {
          elFormItemClassName?: ..., // 修改elFormItem级别的class css的预处理器生成string类型的类名,这里仅支持这种模式传入
          elModuleClassName?: ... // 修改elFormItem以下级别的class
        }, // 自定义组件样式
        elModule?: {
          slotScope?:[{ // 适用以上支持的组件el-module所有插槽
            slotName:'label',
            render: () => h()
          }]
        }, //可选,适用以上支持的组件el-module所有属性
        infinite?: {
          infiniteFn?: () => {}, // 执行函数,默认为() => ({})
          'infinite-scroll-disabled': false // 识别指令写法
        }, // 无限滚动 目前仅支持select,支持无限滚动所有指令
        elOption?: {
          options?: [], // 组件为select时option写在这里,支持select option所有属性
          radioOptions?: [ { label: 'radio1' }, { label: 'radio2' }], // 组件为radio时option写在这里,支持radio所有属性
          radioButtonOptions?: [] // 组件为radioButton时option写在这里,支持radioButton所有属性
        }
      },
      {
        vModel: data2,
        component: 'select',
        ...
      },
      {
        // 某些情况可能需要自定义一些稀奇古怪的东西,您可以直接render
        component: () => h('div',{},'稀奇古怪的东西'), // 必须是一个render函数
      }
    ],
    // 某些情况可能需要自定义,例如标题,或者其他稀奇古怪的东西,您可以直接render
    () => h('div', {}, '标题'), // 必须是一个render函数
    [...]
    ...
  ]
}

特殊情况

您发现在 component 选项中还增加了一个 operation 选项

此选项可让您有些操作可以进入组件内部处理

比如: 最重要的表单验证

我将 ref 实例暴露了出来,让您可以自由操作

这样相比较于自定义写法更规范

// from filter-form.vue
...
provide('formRef', formRef)
...
...
{
    component:'operation',
    operationList?: [ () => h('div',{},'操作1'), () => h('div',{},'操作2'), ...]
}

template 使用

<script setup lang="ts">
...
const getValueFn = (val: any) => {
  console.log(val) // 在此处即可获得处理后的值
}
...
</script>
<template>
  <FilterForm :filterConfig="formConfig" :filterForm="formData" @get-form-value="getValueFn" />
</template>