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

@phoenix_fan/canvas-table

v1.0.4

Published

上万行数据渲染之终极方案:canvas-table

Readme

上万行数据渲染之终极方案:canvas-table

安装

  npm i @phoenix_fan/canvas-table

React 中使用

import React, { useState, useEffect } from 'react';
import CanvasTable from "@phoenix_fan/canvas-table";
/** 引入样式 */
import "@phoenix_fan/canvas-table/lib/index.css";

export default function App() {
    const columns = [
      { label: "序号", key: "index", width: 40 },
      { label: "姓名", key: "name", width: 120 },
      { label: "年龄", key: "age", width: 120 },
      { label: "学校", key: "school", width: 120 },
      { label: "分数分数分数分数分数分数分数分数", key: "source", width: 120 },
      { label: "操作", key: "options", minWidth: 120 },
    ]
    const [data, setData] = useState([]);
    
    const getData = () => {
      return new Promise(resolve => setTimeout(() => {
        const data = new Array(200).fill(null).map((v, i) => ({
          id: ~~(Math.random() * 999999999),
          index: i + 1,
          name: '你好啊',
          age: ~~(Math.random() * 99),
          school: '五道口职业技术学院',
          source: ~~(Math.random() * 150),
        }))
        resolve(data);
      }, 200));
    }
    
    const instance = new Table({
      el: "#app",
      data: data,
      columns,
    })
    
    useEffect(() => {
        getData().then(res => {
            setData(res);
            instance.setData(res);
        })
    }, [])
  
  return (
    <div id="app"></div>
  );
}

Vue中使用

<template>
  <div id="app"></div>
</template>

<script lang="ts" setup>
import { ref, watch } from 'vue';

import CanvasTable from "@phoenix_fan/canvas-table";
/** 引入样式 */
import "@phoenix_fan/canvas-table/lib/index.css";

const data = ref([]);

const columns = [
  { label: "序号", key: "index", width: 60 },
  { label: "姓名", key: "name", width: 120 },
  { label: "年龄", key: "age", width: 120 },
  { label: "学校", key: "school", width: 120 },
  { label: "分数分数分数分数分数分数分数分数", key: "source", width: 120 },
  { label: "操作", key: "options", minWidth: 120 },
]

const getData = () => {
  return new Promise(resolve => setTimeout(() => {
    const data = new Array(200).fill(null).map((v, i) => ({
      id: ~~(Math.random() * 999999999),
      index: i + 1,
      name: '你好啊',
      age: ~~(Math.random() * 99),
      school: '五道口职业技术学院',
      source: ~~(Math.random() * 150),
    }))
    resolve(data);
  }, 200));
}

getData().then(res => data.value = res)



const instance = new Table({
  el: "#app",
  data: tableData,
  columns,
})

watch(data, () => {
  instance.setData(res);
})

</script>

浏览器中使用

<!DOCTYPE html>
<html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Canvas Table</title>
		<link rel="stylesheet" href="node_modules/@phoenix_fan/canvas-table/lib/index.css">
    <script src="node_modules/@phoenix_fan/canvas-table/lib/index.umd.js" ></script>
	</head>
	<body>
    <div id="app"></div>


	<script>
    const columns = [
    { label: "序号", key: "index", width: 60 },
    { label: "姓名", key: "name", width: 120 },
    { label: "年龄", key: "age", width: 120 },
    { label: "学校", key: "school", width: 120 },
    { label: "分数分数分数分数分数分数分数分数", key: "source", width: 120 },
    { label: "操作", key: "options", minWidth: 120 }
    ]

      const tableData = new Array(30).fill(null).map((v, i) => ({
        id: ~~(Math.random() * 999999999),
        index: i + 1,
        name: '你好啊',
        age: ~~(Math.random() * 99),
        school: '五道口职业技术学院',
        source: ~~(Math.random() * 150),
      }))

      const instance = new Table({
        el: "#app",
        data: tableData,
        columns,
      })
		</script>
	</body>
</html>

效果图

效果图

用法

Props | 属性 | 说明 | 类型 | 默认值 | |-----------|--------------|--------------|:--------------:| | el | 挂在节点 | String | - | | data | 渲染组件数据 | Array | - | | column | 渲染组件表格列 | Array | - | | height | 渲染组件高度 | number | - | | rowHeight | 行高 | number 、 row => number | - |

events | 事件名称 | 说明 | 回调参数 | |-----------|--------------|--------------| | onCellClick | 鼠标点击单元格时触发该事件 | cell | | onCellMove | 鼠标移动事件 | |

**Methods ** | 方法名称 | 说明 | 参数 | |-----------|--------------|--------------| | setData | 重新设置表格渲染数据 | cell | | setColumns | 重新设置表格列 | |

Props.column 配置说明(自定义列配置) | 属性 | 说明 | 类型 | 默认值 | |-----------|--------------|--------------|:--------------:| | show | 是否显示列 | Boolean | false | | label | 列中文名 | String | - | | key | 列字段名 | String | - | | width | 列宽 | number | - | | fixed | 是否固定列 | "left" | "right" | - | | headerTooltip | 表头气泡 | string | () => string | - | | tooltip | 单元格气泡 | string | ({ row }) => string | - |