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

xmy-tableform

v1.0.0

Published

基于 Element Plus 的表格表单组合组件,用于在表格中进行表单编辑

Readme

XMY TableForm

一个基于 Element Plus 的表格表单组合组件,用于在表格中进行表单编辑。

安装

npm install xmy-tableform

使用

全局注册

// main.js / main.ts
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import XmyTableForm from 'xmy-tableform'
import App from './App.vue'

const app = createApp(App)
app.use(ElementPlus)
app.use(XmyTableForm)
app.mount('#app')

局部注册

<template>
  <TableForm 
    :columns="columns" 
    v-model:data="tableData" 
    @validate="handleValidate" 
    ref="tableFormRef"
  />
  <el-button @click="validateForm">校验</el-button>
</template>

<script setup>
import { ref, reactive } from 'vue'
import { TableForm } from 'xmy-tableform'
import type { TableFormColumn, TableFormInstance } from 'xmy-tableform'

const tableFormRef = ref()

// 定义列
const columns = reactive([
  {
    label: '姓名',
    prop: 'name',
    editable: true,
    type: 'input',
    rules: [{ required: true, message: '请输入姓名', trigger: 'blur' }]
  },
  {
    label: '年龄',
    prop: 'age',
    editable: true,
    type: 'input',
    props: {
      type: 'number'
    }
  },
  {
    label: '地址',
    prop: 'address',
    editable: true
  }
])

// 表格数据
const tableData = reactive([
  { name: '张三', age: 18, address: '北京' },
  { name: '李四', age: 20, address: '上海' }
])

// 校验回调
const handleValidate = (valid) => {
  console.log('校验结果:', valid)
}

// 手动校验
const validateForm = async () => {
  const valid = await tableFormRef.value.validate()
  if (valid) {
    console.log('校验通过')
  } else {
    console.log('校验不通过')
  }
}
</script>

API

Props

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | columns | 表格列配置 | TableFormColumn[] | [] | | data | 表格数据 | Record<string, any>[] | [] | | inline | 是否行内表单 | boolean | true | | labelWidth | 表单标签宽度 | string | 'auto' |

Events

| 事件名 | 说明 | 回调参数 | | --- | --- | --- | | update:data | 数据更新时触发 | 更新后的数据 | | validate | 表单校验结果 | 是否校验通过 |

Slots

| 插槽名 | 说明 | | --- | --- | | pre-columns | 在表格列之前插入的内容 | | post-columns | 在表格列之后插入的内容 | | [prop]-column | 自定义列的内容,prop为列的prop值 |

方法

| 方法名 | 说明 | 参数 | | --- | --- | --- | | validate | 校验表单 | - |

类型定义

// TableFormColumn 类型
interface TableFormColumn extends Partial<TableColumnCtx<any>> {
  prop: string;
  editable?: boolean;
  type?: 'input' | 'select' | 'date-picker' | 'time-picker' | 'switch' | 'radio' | 'checkbox';
  props?: Record<string, any>;
  rules?: Array<Record<string, any>>;
}

// TableFormInstance 类型
interface TableFormInstance {
  validate: () => Promise<boolean>;
  resetFields: () => void;
  clearValidate: () => void;
}