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

@zenweb/grid-vue-element

v1.10.0

Published

只需要一行代码即可完成数据表格渲染,所有表格项都由服务端返回,减轻前端重复工作。

Downloads

13

Readme

ZenWeb Grid Render for VUE Element UI

只需要一行代码即可完成数据表格渲染,所有表格项都由服务端返回,减轻前端重复工作。

安装说明

需要依赖的版本

  • element-ui: ^2.15.6
  • vue: ^2.6.11
  • vue-template-compiler: ^2.6.11

安装本模块

$ npm i @zenweb/grid-vue-element

在项目中全局启用

import '@zenweb/grid-vue-element/lib/zengrid.css';
import ZenGrid from '@zenweb/grid-vue-element';
Vue.use(ZenGrid);

在项目中使用

<template>
  <zen-grid-render :data="data" @getData="getData" v-loading="loading">
    <template #filter-prepend>
      过滤器左侧插槽
    </template>
    <template #filter-append>
      过滤器右侧插槽
    </template>
    <template #column-prepend>
      <el-table-column>表格左侧列</el-table-column>
    </template>
    <!-- 自定义某一列渲染 -->
    <template #column-by-id>
      <el-table-column label="#" prop="id" />
    </template>
    <template #column-append>
      <el-table-column label="操作">
        <template slot-scope="{row}">
          <el-link type="primary" @click="() => edit(row)">编辑</el-link>&nbsp;
          <el-link type="danger" @click="() => del(row)">删除</el-link>
        </template>
      </el-table-column>
    </template>
    <template #footer-prepend>
      分页左侧插槽
    </template>
    <template #filter-append>
      分页右侧插槽
    </template>
  </zen-grid-render>
</template>

<script>
export default {
  name: 'App',
  data() {
    return {
      data: null,
      loading: true,
    }
  },
  mounted() {
    // 表格不会主动加载数据,第一次打开需要手动加载
    this.getData();
  },
  methods: {
    // grid 在触发过滤、分页时会将 params 参数传递过来
    getData(params) {
      // 加载状态
      this.loading = true;
      // 向服务器请求数据,这里的 $api 由项目提供
      this.$api.get('/some_gird', { params }).then(r => {
        this.data = r;
      }, e => {
        this.$message.error('数据加载错误');
      }).finally(() => {
        this.loading = false;
      });
    },
    edit(row) {
      this.$alert(`编辑数据:${row.id}`);
    },
    del(row) {
      this.$alert(`删除数据:${row.id}`);
    },
  }
}
</script>

自定义数据列

<template #column-by-*="col"> 的内部默认实现代码

<el-table-column
  :key="col.key"
  :prop="col.key"
  :label="col.label || col.key"
  :sortable="col.sortable"
  :width="col.width"
  :min-width="col.minWidth"
  :align="col.align"
/>