blob: 79df16f36f27b8be7c5a9e60213bbbddb4175b51 [file] [log] [blame]
guangchao.xu070005a2020-12-07 09:56:40 +08001<template>
2 <view class="u-table" :style="[tableStyle]">
3 <slot />
4 </view>
5</template>
6
7<script>
8 /**
9 * table 表格
10 * @description 表格组件一般用于展示大量结构化数据的场景
11 * @tutorial https://www.uviewui.com/components/table.html
12 * @property {String} border-color 表格边框的颜色(默认#e4e7ed)
13 * @property {String} bg-color 表格的背景颜色(默认#ffffff)
14 * @property {String} align 单元格的内容对齐方式,作用类似css的text-align(默认center)
15 * @property {String} padding 单元格的内边距,同css的padding写法(默认10rpx 0)
16 * @property {String Number} font-size 单元格字体大小,单位rpx(默认28)
17 * @property {String} color 单元格字体颜色(默认#606266)
18 * @property {Object} th-style th单元格的样式,对象形式(将th所需参数放在table组件,是为了避免每一个th组件要写一遍)
19 * @event {Function} click 点击组件时触发
20 * @event {Function} close 点击关闭按钮时触发
21 * @example <u-table></u-table>
22 */
23 export default {
24 name: "u-table",
25 props: {
26 borderColor: {
27 type: String,
28 default: '#e4e7ed'
29 },
30 align: {
31 type: String,
32 default: 'center'
33 },
34 // td的内边距
35 padding: {
36 type: String,
37 default: '10rpx 6rpx'
38 },
39 // 字体大小
40 fontSize: {
41 type: [String, Number],
42 default: 28
43 },
44 // 字体颜色
45 color: {
46 type: String,
47 default: '#606266'
48 },
49 // th的自定义样式
50 thStyle: {
51 type: Object,
52 default () {
53 return {}
54 }
55 },
56 // table的背景颜色
57 bgColor: {
58 type: String,
59 default: '#ffffff'
60 }
61 },
62 data() {
63 return {}
64 },
65 computed: {
66 tableStyle() {
67 let style = {};
68 style.borderLeft = `solid 1px ${this.borderColor}`;
69 style.borderTop = `solid 1px ${this.borderColor}`;
70 style.backgroundColor = this.bgColor;;
71 return style;
72 }
73 }
74 }
75</script>
76
77<style lang="scss" scoped>
78 @import "../../libs/css/style.components.scss";
79
80 .u-table {
81 width: 100%;
82 box-sizing: border-box;
83 }
84</style>