基于vue3开发mobile-table适用于移动端表格
mobile-table 适用于移动端表格基于vue3开发的移动端table表格组件安装npm i mobile-table// oryarn add mobile-table使用// 导入组件imp
mobile-table 适用于移动端表格
基于vue3
开发的移动端table
表格组件
安装
npm i mobile-table
// or
yarn add mobile-table
使用
// 导入组件
import { mobiletable, mobiletablecolumn } from "mobile-table";
// 导入样式
import "mobile-table/lib/style.css";
预览


mobiletable 属性说明
属性名 | 说明 | 类型 | 默认值 | 说明 |
---|
data | table 数据 | array | array | |
sortkey | 排序字段 | string | ‘’ | |
sorttype | 排序类型 | number | 0 | |
paging | 是开启分页 | boolean | false | |
pageindex | 分页索引 | number | 1 | |
pagetotal | 总分页数 | number | 1 | |
mobiletable 事件说明
方法 | 说明 | 类型 | 说明 |
---|
sortchange | 排序字段和排序方法 变化 | function | ({ sortkey: string, sorttype: number })=> void |
pagechange | pageindex 分页变化 | function | (index: number)=> void |
mobiletablecolumn 属性说明
属性名 | 说明 | 类型 | 默认值 | 说明 |
---|
label | 对应列名称 | string | ‘’ | |
prop | 对应列字段 | string | ‘’ | |
width | 对应列的宽度 | number | auto | |
sort | 对应列是否开启排序 | boolean | false | |
align | 对应列的对齐方式 | string | left | left center right |
基本用法
<template>
<mobiletable :data="data" >
<mobiletablecolumn name="姓名" prop="name" />
<mobiletablecolumn name="年龄" prop="age" />
<mobiletablecolumn name="性别" prop="sex">
<template #default="scope">
<div>{{ scope.row.sex === 1 ? "男" : "女" }}</div>
</template>
</mobiletablecolumn>
</mobiletable>
</template>
<script setup>
// 引入组件
import { mobiletable, mobiletablecolumn } from "mobile-table";
import "mobile-table/lib/style.css";
import { ref } from "vue";
// 表格数据
const data = ref([
{
name: "张三",
age: 18,
sex: 1,
},
{
name: "李四",
age: 18,
sex: 1,
},
{
name: "王小红",
age: 18,
sex: 2,
},
]);
</script>
<style scoped></style>
所有配置 支持分页 支持排序
<template>
<mobiletable
:data="data"
:sortkey="sortkey"
:sorttype="sorttype"
:paging="isshowpaging"
:pageindex="pageindex"
:pagetotal="pagetotal"
@sortchange="onsortchange"
@pagechange="onpagechange"
>
<mobiletablecolumn name="姓名" prop="name" />
<mobiletablecolumn name="年龄" prop="age" :sort="true" />
<mobiletablecolumn name="性别" prop="sex">
<template #default="scope">
<div>{{ scope.row.sex === 1 ? "男" : "女" }}</div>
</template>
</mobiletablecolumn>
</mobiletable>
</template>
<script setup>
import { mobiletable, mobiletablecolumn } from "mobile-table";
import "mobile-table/lib/style.css";
import { ref } from "vue";
// 表格数据
const data = ref([
{
name: "张三",
age: 18,
sex: 1,
},
{
name: "李四",
age: 18,
sex: 1,
},
{
name: "王小红",
age: 18,
sex: 2,
},
]);
// 排序
const sortkey = ref("name");
const sorttype = ref(1);
// 分页
const isshowpaging = ref(true);
const pageindex = ref(1);
const pagetotal = ref(12);
// 修改排序
function onsortchange(option = {}) {
sortkey.value = option.sortkey;
sorttype.value = option.sorttype;
}
// 修改分页
function onpagechange(index) {
pageindex.value = index;
}
</script>
<style scoped></style>
总结
到此这篇关于如何基于vue3开发mobile-table适用于移动端表格的文章就介绍到这了,更多相关vue3 mobile-table移动端表格内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!
相关文章:
-
ES6基础语法之函数介绍
一、函数参数的扩展es6支持参数的默认值:function fn(name,age,sex="男"){console.log(`大家好,我是${name},性别...
[阅读全文]
-
-
-
-
ES6基础语法之模块化介绍
es6 引入了模块化, es6 的模块化分为导出(export) @与导入(import)两个模块。es6模块化特点:(1)es6 的模块自动开启严格模式,不管...
[阅读全文]
-
版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。
发表评论