vue uikit_使用vue和uikit3构建的自定义数据表

本文介绍了如何使用Vue和UIKit3框架构建一个简单的数据表组件。内容包括通过npm或yarn安装,基本使用示例,如何启用或禁用复选框选择功能,以及如何添加搜索框功能来过滤数据。
摘要由CSDN通过智能技术生成

vue uikit

vue-uikit-datatable (vue-uikit-datatable)

A Simple Datatable for the UiKit 3.0 Framework.

UiKit 3.0框架的简单数据表。

For npm:

对于npm:

npm install vue-uikit-datatable

For yarn

纱线用

yarn add vue-uikit-datatable

使用 (To Use)

Import the Datatable by using

通过使用导入数据表

import Vue from 'vue'
import Datatable from 'vue-uikit-table'
Vue.use(Datatable)

基本范例 (Basic Example)

<template>
    <section class="uk-container uk-section">
        <Datatable :titles="titles" :itemList="usersList"></Datatable>
    </section>
</template>

<script>
const titles = [
  {
    prop: "username",
    name: "Username"
  },
  {
    prop: "email",
    name: "Email"
  },
  {
    prop: "gender",
    name: "Gender"
  }
];

const usersList = [
{
    "id": "1",
    "username": "hirthe.alyson",
    "email": "[email protected]",
    "gender": "male",
},
{
    "id": "2",
    "username": "oklein",
    "email": "[email protected]",
    "gender": "male",
},
{
    "id": "3",
    "username": "bahringer.leonel",
    "email": "[email protected]",
    "gender": "female",
}];

export default {
  name: "UserControls",
  data() {
    return {
      titles,
      usersList
    };
  },
  methods: {
  }
};
</script>

对于复选框选择 (For Checkbox selection)

Checkbox selection is on by default, remove it by using the prop checkbox-filter

默认情况下,复选框选择处于启用状态,请使用prop checkbox-filter将其删除

:checkbox-filter=false

To process get the items selected, add selected-change

要处理以获取选定项目,请添加selected-change

@selected-change='function-to-handle-selected-items'

(Example)

<Datatable :checkbox-filter=true @selected-change='selected'></Datatable>

data(){
    items:[]
}
methods:{
selected(items) {
      console.log(items);
    }
}

使用搜索框 (To Use Search Box)

Add the prop search-attrs

添加道具search-attrs

:searchAttrs="columns-to-be-searched"

(Example)

<Datatable :search-attrs="searchAttrs"></Datatable>

<script>
export default{
    data(){
        return{
            searchAttrs: ["username","email"],
        }
    }
}
</script>

翻译自: https://vuejsexamples.com/a-custom-data-table-built-using-vue-and-uikit3/

vue uikit

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值