blob: 9fe5a164ad2dae1bf4d70fb71c7ee1b38ef166a5 [file] [log] [blame]
guangchao.xu070005a2020-12-07 09:56:40 +08001<template>
2 <view class="u-th" :style="[thStyle]">
3 <slot></slot>
4 </view>
5</template>
6
7<script>
8 /**
9 * th th单元格
10 * @description 表格组件一般用于展示大量结构化数据的场景(搭配u-table使用)
11 * @tutorial https://www.uviewui.com/components/table.html#td-props
12 * @property {String Number} width 标题单元格宽度百分比或者具体带单位的值,如30%,200rpx等,一般使用百分比,单元格宽度默认为均分tr的长度
13 * @example 暂无示例
14 */
15 export default {
16 name: "u-th",
17 props: {
18 // 宽度,百分比或者具体带单位的值,如30%, 200rpx等,一般使用百分比
19 width: {
20 type: [Number, String],
21 default: ''
22 }
23 },
24 data() {
25 return {
26 thStyle: {}
27 }
28 },
29 created() {
30 this.parent = false;
31 },
32 mounted() {
33 this.parent = this.$u.$parent.call(this, 'u-table');
34 if (this.parent) {
35 // 将父组件的相关参数,合并到本组件
36 let style = {};
37 if (this.width) style.flex = `0 0 ${this.width}`;
38 style.textAlign = this.parent.align;
39 style.padding = this.parent.padding;
40 style.borderBottom = `solid 1px ${this.parent.borderColor}`;
41 style.borderRight = `solid 1px ${this.parent.borderColor}`;
42 Object.assign(style, this.parent.style);
43 this.thStyle = style;
44 }
45 }
46 };
47</script>
48
49<style lang="scss" scoped>
50 @import "../../libs/css/style.components.scss";
51
52 .u-th {
53 @include vue-flex;
54 flex-direction: column;
55 flex: 1;
56 justify-content: center;
57 font-size: 28rpx;
58 color: $u-main-color;
59 font-weight: bold;
60 background-color: rgb(245, 246, 248);
61 }
62</style>