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

vue3-pro-element-h

v0.0.2

Published

a vue music player

Readme

✅ 功能亮点

| 📋 支持动态列配置(columns) | 可定义字段绑定、自定义渲染函数 | | ------------------------------ | ----------------------------------------- | | 🔍 搜索栏自动构建 | 标记search: true的列会出现在搜索表单中 | | 🖼 自定义单元格渲染 | 支持h()函数返回 VNode(如图片、开关等) | | 📄 分页加载数据 | 支持翻页,并触发远程请求 | | ⏳ Loading 状态 | 表格加载时显示 loading 效果 | | 🔁 数据刷新机制 | 支持搜索、重置操作 |


🧰 技术栈

| 框架 | Vue 3 + Composition API | | -------- | ---------------------------------------- | | UI 库 | Element Plus | | 构建工具 | Vite / Webpack | | 渲染方式 | JSX +h()虚拟节点 | | 开发语言 | TypeScript / JavaScript |


📦 安装与引入

在你的 Vue 项目中安装依赖:

npm install element-plus

引入组件:

import ProTable from "@/components/proTable/index.vue";

在模板中使用:

<template>
  <pro-table :columns="columns" @request="handleRequest" :is-pagination="true" />
</template>

🧱 props 参数说明

| columns | Array | ✅ 是 | 列配置数组,支持字段绑定、搜索项、自定义渲染 | | -------------- | -------- | ----- | ------------------------------------------------------------- | | isPagination | Boolean | ❌ 否 | 是否启用分页,默认为false | | request | Function | ✅ 是 | 数据请求回调函数,需返回数据并执行callback({ data, total }) |


🧩 columns 配置详解

每个 column 支持以下属性:

| prop | string | ✅ 是 | 对应数据字段名(如name,age) | | --------- | -------- | ----- | ---------------------------------- | | label | string | ✅ 是 | 表头显示文本 | | type | string | ❌ 否 | 特殊类型(如index,selection) | | width | string | ❌ 否 | 列宽度(如"100px") | | fixed | string | ❌ 否 | 固定列(如"right") | | search | boolean | ❌ 否 | 是否出现在搜索栏中 | | formate | function | ❌ 否 | 自定义表单项渲染函数(用于搜索栏) | | h | function | ❌ 否 | 自定义单元格渲染函数(用于表格内) |

`---

🧪 使用示例

示例代码:

<script setup lang="jsx">
import { ref } from "vue";
import ProTable from "@/components/proTable/index.vue";
import { h } from "vue";
import {
  ElImage,
  ElSwitch,
  ElButton,
  ElSelect,
  ElOption
} from "element-plus";

const columns = ref([
  {
    type: "selection"
  },
  {
    type: "index",
    label: "序号",
    width: "100"
  },
  {
    prop: "name",
    label: "姓名",
    search: true
  },
  {
    prop: "age",
    label: "年龄",
    search: true
  },
  {
    prop: "sex",
    label: "性别",
    search: true,
    formate: () =>
      h(ElSelect, {
        style: { width: '120px' },
        placeholder: "请选择性别"
      }, [
        h(ElOption, { value: "", label: "全部" }),
        h(ElOption, { value: "男", label: "男" }),
        h(ElOption, { value: "女", label: "女" })
      ])
  },
  {
    prop: "url",
    label: "头像",
    h: (row) =>
      h(ElImage, {
        src: row.url,
        previewSrcList: [row.url],
        previewTeleported: true,
        style: { width: "60px", height: "60px" }
      })
  },
  {
    prop: "status",
    label: "状态",
    h: (row) =>
      h(ElSwitch, {
        modelValue: row.status,
        "onUpdate:modelValue": (val) => {
          row.status = val;
          console.log("状态更新:", val);
        }
      })
  },
  {
    label: "操作",
    fixed: "right",
    h: (row) =>
      h("div", {}, [
        h(
          ElButton,
          {
            props: { size: "small", type: "primary" },
            on: { click: () => console.log("添加", row) }
          },
          "添加"
        ),
        h(
          ElButton,
          {
            props: { size: "small", type: "danger" },
            on: { click: () => console.log("删除", row) }
          },
          "删除"
        )
      ])
  }
]);

// 请求处理函数(模拟数据)
const handleRequest = ({ pagination, callback, searchForm }) => {
  setTimeout(() => {
    const mockData = Array.from({ length: 10 }, (_, i) => ({
      name: `用户${i + 1}`,
      sex: i % 2 === 0 ? "男" : "女",
      age: 20 + i,
      status: i % 2 === 0,
      url: "https://pic35.photophoto.cn/20150511/0034034892281415_b.jpg "
    }));

    callback({
      data: mockData,
      total: 50
    });
  }, 500);
};
</script>

<template>
  <pro-table :columns="columns" @request="handleRequest" :is-pagination="true" />
</template>

📋 方法说明

| onSearch() | 触发一次搜索请求 | | ------------ | ------------------------------------------------- | | onReset() | 重置所有搜索条件,并重新加载数据 | | v-model | 所有搜索字段都双向绑定到searchForm[column.prop] |