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

@moluoxixi/configform

v1.3.10

Published

ConfigForm 组件

Downloads

20

Readme

用法:

formOptions对应el-form配置项,
    formOptions.model对应表单数据,
    formOptions.model会传递给render函数和type对应的组件

rows对应每一行,
    rows中的成员属性,除formItems外,其余配置项会作为el-row配置项

    formItems其成员对应每一列,其成员属性:
        type用于指定使用的内置组件类型,

        render对应自定义jsx,
        renderSlot:'插槽名称',接受configForm的对应插槽,

        tooltipConfig,popoverConfig,popconfirmConfig,分别用来启用每一列是否启用tooltip,popover,popconfirm及其配置项

        slots用于自定义每一列自定义组件的插槽内容,

        colConfig作为el-col配置项,

        其余配置项会传递给el-form-item

eg:

<template>
  <wlConfigForm ref="form" :form-options="formOptions" :rows.sync="rows">
    <template #aaa>
      <div>aaa</div>
    </template>
  </wlConfigForm>
</template>

<script>
import { formOptions, getRows } from "./data";
import {defineComponent} from 'vue'
export default defineComponent({
  data() {
    return {
      formOptions,
      rows: getRows.call(this)
    };
  }
};
</script>
// ./data.js

export function getRows() {
  return [
    {
      formItems: [
        {
          prop: 'cmdName',
          label: '名称:',
          renderSlot: 'aaa',
        },
        {
          type: 'input',
          prop: 'a',
          label: '名称:',
          colConfig: { span: 4 },
          config: {
            placeholder: '请输入名称',
          },
        },
        {
          type: 'select',
          prop: 'b',
          label: '名称:',
          config: {
            options: [{ label: '测试', value: '1' }],
          },
        },
      ],
    },
  ]
}

export const formOptions = {
  required: true,
  model: {
    a: '',
  },
}

传递 slot 自定义列

rows:[
    {
        formItems: [
            {
              renderSlot: 'aaa' //aaa对应configForm的插槽名称
            }
        ]
    },
]

给指定组件传递slots

rows:[
    {
        formItems: [
            {
              type: 'button',
              config: {
                slots: {
                  default: 'aaa'  //aaa对应configForm的插槽名称
                },
              }
            }
        ]
    },
]

动态修改属性

this.$refs.form.setConfigByProp('a', 'xxx', 'placeholder');

this.$refs.form.setConfigByProp('b', [ {label: '测试',value: '1'}], true);
//等同于
this.$refs.form.setConfigByProp('b', [ {label: '测试',value: '1'}]);
this.$refs.form.setConfigByProp('b', [ {label: '测试',value: '1'}],'options');

this.$refs.form.setColConfigByProp('b', {span: 4});

this.$refs.form.setFormItemByProp('a', '你好', 'label');

formItems

el-select

{
  type: 'select',
  colConfig: {span: 4},
  // 可使用这个,将options的label和value映射到其他属性上
  optionsMap: {
    label: 'aaa'
  },
  prop: 'a',
  config: { options: [ {aaa: '测试',value: '1'}]}
},

el-switch

{
  type: 'switch',
  colConfig: { span: 4},
  prop: 'b',
  config: {}
},

el-input

{
  type: 'input',
  colConfig: {span: 4},
  prop: 'c',
  config: {}
},

el-slider

{
  type: 'slider',
  colConfig: {span: 4},
  prop: 'c',
  config: {}
},

el-table+el-table-column

{
  type: 'table',
  colConfig: {span: 4},
  prop: 'd',
  config: {columns: [{ label: '服务', width: '250', prop: 'serviceName' }]}
}

el-checkbox

{
  type: 'checkbox',
  colConfig: {span: 4},
  prop: 'd',
  config: {}
}

el-checkbox-group+el-checkbox

{
  type: 'checkboxGroup',
  colConfig: { span: 4},
  prop: 'b',
  config: {
    checkboxs:[{label:'1'}]
  }
},

el-checkbox-group+el-checkbox-button

{
  type: 'checkboxGroup',
  colConfig: { span: 4},
  prop: 'b',
  config: {
    buttons:[{label:'1'}]
  }
},

待优化点:

目前只支持栅栏布局,
    做成支持flex布局,自己写宽度,剩余flex1
        rows中传一个type:flex,此时不使用el-row和el-col
    支持普通div,
        rows中传一个type:div,此时不使用el-row和el-col

稳定后,支持可视化生成