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

vue-mergeable-table

v1.0.9

Published

Vue 动态生成的可跨行跨列的表格

Downloads

19

Readme

简介

可以根据数据动态生成可合并行列的表格。

文档

在线 DEMO

数据选项

options

数据选项有 3 个字段要注意:

  1. conten,单元格内容字段
  2. class,单元格类名字段
  3. merge,这是一个对象,数据为要合并表格的相关数据。它也有一个 class 字段,并且它会覆盖第 2 点中的 class 字段,优先级较高。

highlight

高亮属性,鼠标移动到单元格时,单元格背景颜色改变。

options: {
    cols: 6, // 要生成的表格列数
    rows: 7, // 要生成的表格行数 这个表是 7 * 6
    data: [ // 表格数据,生成表格后将数据按顺序一一填充到表格
        { content: '测试1', id: 10, a: 100, b: 100, class: 'test' }, // content 字段为表格的内容
        // 需要合并的数据需要填入一个 merge 对象
        // row col 为起始行列,rowspan 和 colspan 为合并的行数,值默认为 1,为 1 时可以不填
        // 这代表这个数据要放在 row 为 3,col 为 1 的单元格上,并且占 3 行 1列
        { content: '测试2', merge: { row: 3, col: 0, rowspan: 3 } },
        { content: '测试3' },
    ],
},

事件

组件可监听 click 事件,事件回调函数参数格式:

// 当前点击的数据 行数据 行索引 列索引,返回的行数据 行索引 列索引均以合并后的表格为准
handleClick(data, rowData, row, col) {
    console.log(data)
    console.log(rowData)
    console.log(row)
    console.log(col)
},

注意事项

假设你创建了一个 4*4 的表格,如下图所示。

现在每一行你都合并了 3 列,这时表格会发生崩溃现象。

这是表格自身的问题,和组件无关。要解决此问题,只需再加一行没有合并的表格把表格撑开即可。

使用

在单文件组件中引用

npm i vue-mergeable-table
import VueMergeableTable from 'vue-mergeable-table'

Vue.use(VueMergeableTable)
<template>
    <div id="app">
        <VueMergeableTable :options="options" @click="handleClick" />
        // 或者 <vue-mergeable-table :options="options"/>
    </div>
</template>

在HTML文件中直接引用

使用的是dist目录中的 vue-mergeable-table.js

<div id="app">
    <vue-mergeable-table :options="options" @click="handleClick"></vue-mergeable-table>
</div>