c7add6cf
“wangming”
初始版本开发完毕
|
1
|
<template>
|
25852764
unknown
s
|
2
3
|
<view class="u-td" :style="[tdStyle]">
<slot></slot>
|
c7add6cf
“wangming”
初始版本开发完毕
|
4
5
6
7
|
</view>
</template>
<script>
|
25852764
unknown
s
|
8
9
10
11
12
13
|
/**
* td td单元格
* @description 表格组件一般用于展示大量结构化数据的场景(搭配u-table使用)
* @tutorial https://www.uviewui.com/components/table.html#td-props
* @property {String Number} width 单元格宽度百分比或者具体带单位的值,如30%, 200rpx等,一般使用百分比,单元格宽度默认为均分tr的长度(默认auto)
* @example <u-td>二年级</u-td>
|
c7add6cf
“wangming”
初始版本开发完毕
|
14
15
|
*/
export default {
|
25852764
unknown
s
|
16
17
18
19
20
21
22
23
|
name: "u-td",
props: {
// 宽度,百分比或者具体带单位的值,如30%, 200rpx等,一般使用百分比
width: {
type: [Number, String],
default: 'auto'
}
},
|
c7add6cf
“wangming”
初始版本开发完毕
|
24
25
|
data() {
return {
|
25852764
unknown
s
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
tdStyle: {
}
}
},
created() {
this.parent = false;
},
mounted() {
this.parent = this.$u.$parent.call(this, 'u-table');
if (this.parent) {
// 将父组件的相关参数,合并到本组件
let style = {};
if (this.width != "auto") style.flex = `0 0 ${this.width}`;
style.textAlign = this.parent.align;
style.fontSize = this.parent.fontSize + 'rpx';
style.padding = this.parent.padding;
style.borderBottom = `solid 1px ${this.parent.borderColor}`;
style.borderRight = `solid 1px ${this.parent.borderColor}`;
style.color = this.parent.color;
this.tdStyle = style;
|
c7add6cf
“wangming”
初始版本开发完毕
|
47
48
|
}
}
|
25852764
unknown
s
|
49
|
};
|
c7add6cf
“wangming”
初始版本开发完毕
|
50
51
52
|
</script>
<style lang="scss" scoped>
|
25852764
unknown
s
|
53
54
55
56
57
58
59
60
61
62
63
64
65
|
@import "../../libs/css/style.components.scss";
.u-td {
@include vue-flex;
flex-direction: column;
flex: 1;
justify-content: center;
font-size: 28rpx;
color: $u-content-color;
align-self: stretch;
box-sizing: border-box;
height: 100%;
}
|
c7add6cf
“wangming”
初始版本开发完毕
|
66
|
</style>
|