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

vable

v0.0.1

Published

vue.js table

Downloads

4

Readme

VTable

vue.js 表格效果

使用

<!DOCTYPE html>
<html>
<head>
	<title>简单表格</title>
	<!-- 1.表格样式 -->
	<link rel="stylesheet" type="text/css" href="src/VTable.css">
	...
</head>
<body>
    <!-- 3.表格内容 -->
	<div id="show-table">
		<!-- 5.使用 VTable 组件生成表格 -->
		<v-table 
			:header="tableHeader" 
			:data="tableData"
		></v-table>
	</div>
  
    <!-- 2.VTable html 引用模板: src/template.html -->
    <script type="text/x-template" id="v-table-mod">
    ...
    </script>
  
    <script>
    // 4.实例化
    var table = new Vue({
        el: '#show-table',
        data: {
            // 表格中间内容
            tableData: {},
            // 表格的头信息,具体参考 demo
            tableHeader: {}
        },
        mounted: function () {
            var _ = this;

            // 加载数据
            $.ajax({
                url: 'mock/table.json',
                type: 'get'
            })
            .done(function(data) {
                // 赋值给表格
                _.tableData = data
            })
            .fail(function(err) {
                // 请求数据错误时
                console.error(err)
            })
        },
        methods: {
          holleEvt: function (data) {
            console.log(data)
            // data 返回以下信息
            /*
            	// 当前状态
            	status: true,
            	// 状态翻译
				statusMes: '展开',
				// 当前行信息
				tr: {
					index: 0,
					data: {...}
				},
				// 当前 td 信息
				td: {
					index: 0,
					data: {...}
				}
            */
          }
        }
    })
    </script>
</body>
</html>
  1. 引用样式表

  2. 添加组件模板(可以通过 ajax 加,参考 VTable.html)

  3. 添加你要的生成的元素

  4. 实例化对象,添加表格头等相关信息

  5. 添加组件引用 VTable

参数

主体说明

| 参数 | 说明 | | ------ | ------------------------- | | header | 表格头信息(必填) | | data | 表格主体信息(必填) | | left | 表格左侧信息(非必填) | | toggle | 事件,展开收缩功能,返回状态与信息 | | scroll | 事件,返回当前滚动条的信息,{top, left} |

<v-table 
    :header="tableHeader" 
    :data="tableData"
    left="tableLeft"
    @toggle="your_toggle_Evt"
    @scroll="your_scroll_evt"
></v-table>

头部说明

| 参数 | 说明 | | -------- | ----------------------- | | text | 显示内容 | | width | 列宽,没有children时添加 | | children | 子表信息 | | type | leftAside 侧边专用,用于突出侧边区域 |

// 表格头
var header = [
    {
        "text": "时间",
        "width": 400,
        "type": "leftAside"
    },
    {
        "text": "2017",
        "children": [
            {
                "text": "Q1",
                "children": [
                    {
                        "text": "1月",
                        "width": 100
                    },
                    {
                        "text": "2月",
                        "width": 100
                    },
                    {
                        "text": "3月",
                        "width": 100
                    }
                ]
            }
          ]
    }
  ]