|
17 | 17 | color: subColor
|
18 | 18 | }" @tap="rightClick">
|
19 | 19 | {{subTitle}}
|
20 |
| - <view class="u-section__right-info__icon-arrow u-flex"> |
21 |
| - <u-icon v-if="arrow" name="arrow-right" size="24" :color="subColor"></u-icon> |
| 20 | + <view class="u-section__right-info__icon-arrow u-flex" v-if="arrow"> |
| 21 | + <u-icon name="arrow-right" size="24" :color="subColor"></u-icon> |
22 | 22 | </view>
|
23 | 23 | </view>
|
24 | 24 | </view>
|
25 | 25 | </template>
|
26 | 26 |
|
27 | 27 | <script>
|
28 |
| - /** |
29 |
| - * section 查看更多 |
30 |
| - * @description 该组件一般用于分类信息有很多,但是限于篇幅只能列出一部分,让用户通过"查看更多"获得更多信息的场景,实际效果见演示。 |
31 |
| - * @tutorial https://www.uviewui.com/components/section.html |
32 |
| - * @property {String} title 左边主标题 |
33 |
| - * @property {String} sub-title 右边副标题(默认更多) |
34 |
| - * @property {Boolean} right 是否显示右边的内容(默认true) |
35 |
| - * @property {Boolean} showLine 是否显示左边的竖条(默认true) |
36 |
| - * @property {String Number} font-size 主标题的字体大小(默认28) |
37 |
| - * @property {Boolean} bold 主标题是否加粗(默认true) |
38 |
| - * @property {String} color 主标题颜色(默认#303133) |
39 |
| - * @property {Boolean} arrow 是否显示右侧箭头(默认true) |
40 |
| - * @event {Function} click 组件右侧的内容被点击时触发,用于跳转"更多" |
41 |
| - * @example <u-section title="今日热门" :right="false"></u-section> |
42 |
| - */ |
43 |
| - export default { |
44 |
| - name: "u-section", |
45 |
| - props: { |
46 |
| - // 标题信息 |
47 |
| - title: { |
48 |
| - type: String, |
49 |
| - default: '' |
50 |
| - }, |
51 |
| - // 右边副标题内容 |
52 |
| - subTitle: { |
53 |
| - type: String, |
54 |
| - default: '更多' |
55 |
| - }, |
56 |
| - // 是否显示右边的内容 |
57 |
| - right: { |
58 |
| - type: Boolean, |
59 |
| - default: true |
60 |
| - }, |
61 |
| - fontSize: { |
62 |
| - type: [Number, String], |
63 |
| - default: 28 |
64 |
| - }, |
65 |
| - // 主标题是否加粗 |
66 |
| - bold: { |
67 |
| - type: Boolean, |
68 |
| - default: true |
69 |
| - }, |
70 |
| - // 主标题的颜色 |
71 |
| - color: { |
72 |
| - type: String, |
73 |
| - default: '#303133' |
74 |
| - }, |
75 |
| - // 右边副标题的颜色 |
76 |
| - subColor: { |
77 |
| - type: String, |
78 |
| - default: '#909399' |
79 |
| - }, |
80 |
| - // 是否显示左边的竖条 |
81 |
| - showLine: { |
82 |
| - type: Boolean, |
83 |
| - default: true |
84 |
| - }, |
85 |
| - // 左边竖线的颜色 |
86 |
| - lineColor: { |
87 |
| - type: String, |
88 |
| - default: '' |
89 |
| - }, |
90 |
| - // 是否显示右侧箭头 |
91 |
| - arrow: { |
92 |
| - type: Boolean, |
93 |
| - default: true |
94 |
| - } |
| 28 | +/** |
| 29 | + * section 查看更多 |
| 30 | + * @description 该组件一般用于分类信息有很多,但是限于篇幅只能列出一部分,让用户通过"查看更多"获得更多信息的场景,实际效果见演示。 |
| 31 | + * @tutorial https://www.uviewui.com/components/section.html |
| 32 | + * @property {String} title 左边主标题 |
| 33 | + * @property {String} sub-title 右边副标题(默认更多) |
| 34 | + * @property {Boolean} right 是否显示右边的内容(默认true) |
| 35 | + * @property {Boolean} arrow 是否显示右边箭头(默认true) |
| 36 | + * @property {Boolean} showLine 是否显示左边的竖条(默认true) |
| 37 | + * @property {String Number} font-size 主标题的字体大小(默认28) |
| 38 | + * @property {Boolean} bold 主标题是否加粗(默认true) |
| 39 | + * @property {String} color 主标题颜色(默认#303133) |
| 40 | + * @event {Function} click 组件右侧的内容被点击时触发,用于跳转"更多" |
| 41 | + * @example <u-section title="今日热门" :right="false"></u-section> |
| 42 | + */ |
| 43 | +export default { |
| 44 | + name: "u-section", |
| 45 | + props: { |
| 46 | + // 标题信息 |
| 47 | + title: { |
| 48 | + type: String, |
| 49 | + default: '' |
95 | 50 | },
|
96 |
| - computed: { |
97 |
| - // 左边竖条的样式 |
98 |
| - lineStyle() { |
99 |
| - // 由于安卓和iOS的,需要稍微调整绝对定位的top值,才能让左边的竖线和右边的文字垂直居中 |
100 |
| - return { |
101 |
| - // 由于竖线为字体图标,具有比实际线宽更宽的宽度,所以也需要根据字体打下动态调整 |
102 |
| - left: -(Number(this.fontSize) * 0.9) + 'rpx', |
103 |
| - top: -(Number(this.fontSize) * (this.$u.os == 'ios' ? 0.14 : 0.15)) + 'rpx', |
104 |
| - } |
105 |
| - } |
| 51 | + // 右边副标题内容 |
| 52 | + subTitle: { |
| 53 | + type: String, |
| 54 | + default: '更多' |
| 55 | + }, |
| 56 | + // 是否显示右边的内容 |
| 57 | + right: { |
| 58 | + type: Boolean, |
| 59 | + default: true |
| 60 | + }, |
| 61 | + fontSize: { |
| 62 | + type: [Number, String], |
| 63 | + default: 28 |
| 64 | + }, |
| 65 | + // 主标题是否加粗 |
| 66 | + bold: { |
| 67 | + type: Boolean, |
| 68 | + default: true |
| 69 | + }, |
| 70 | + // 主标题的颜色 |
| 71 | + color: { |
| 72 | + type: String, |
| 73 | + default: '#303133' |
| 74 | + }, |
| 75 | + // 右边副标题的颜色 |
| 76 | + subColor: { |
| 77 | + type: String, |
| 78 | + default: '#909399' |
| 79 | + }, |
| 80 | + // 是否显示左边的竖条 |
| 81 | + showLine: { |
| 82 | + type: Boolean, |
| 83 | + default: true |
| 84 | + }, |
| 85 | + // 左边竖线的颜色 |
| 86 | + lineColor: { |
| 87 | + type: String, |
| 88 | + default: '' |
| 89 | + }, |
| 90 | + // 是否显示右边箭头 |
| 91 | + arrow: { |
| 92 | + type: Boolean, |
| 93 | + default: true |
106 | 94 | },
|
107 |
| - methods: { |
108 |
| - rightClick() { |
109 |
| - this.$emit('click'); |
| 95 | + }, |
| 96 | + computed: { |
| 97 | + // 左边竖条的样式 |
| 98 | + lineStyle() { |
| 99 | + // 由于安卓和iOS的,需要稍微调整绝对定位的top值,才能让左边的竖线和右边的文字垂直居中 |
| 100 | + return { |
| 101 | + // 由于竖线为字体图标,具有比实际线宽更宽的宽度,所以也需要根据字体打下动态调整 |
| 102 | + left: -(Number(this.fontSize) * 0.9) + 'rpx', |
| 103 | + top: -(Number(this.fontSize) * (this.$u.os == 'ios' ? 0.14 : 0.15)) + 'rpx', |
110 | 104 | }
|
111 | 105 | }
|
| 106 | + }, |
| 107 | + methods: { |
| 108 | + rightClick() { |
| 109 | + this.$emit('click'); |
| 110 | + } |
112 | 111 | }
|
| 112 | +} |
113 | 113 | </script>
|
114 | 114 |
|
115 | 115 | <style lang="scss" scoped>
|
116 |
| - @import "../../libs/css/style.components.scss"; |
| 116 | +@import "../../libs/css/style.components.scss"; |
| 117 | +
|
| 118 | +.u-section { |
| 119 | + display: flex; |
| 120 | + justify-content: space-between; |
| 121 | + align-items: center; |
| 122 | + width: 100%; |
117 | 123 |
|
118 |
| - .u-section { |
| 124 | + &__title { |
| 125 | + position: relative; |
| 126 | + font-size: 28rpx; |
| 127 | + padding-left: 20rpx; |
119 | 128 | display: flex;
|
120 |
| - justify-content: space-between; |
121 | 129 | align-items: center;
|
122 |
| - width: 100%; |
123 |
| -
|
124 |
| - &__title { |
125 |
| - position: relative; |
126 |
| - font-size: 28rpx; |
127 |
| - padding-left: 20rpx; |
128 |
| - display: flex; |
129 |
| - align-items: center; |
130 | 130 |
|
131 |
| - &__icon-wrap { |
132 |
| - position: absolute; |
133 |
| - } |
| 131 | + &__icon-wrap { |
| 132 | + position: absolute; |
| 133 | + } |
134 | 134 |
|
135 |
| - &__text { |
136 |
| - line-height: 1; |
137 |
| - } |
| 135 | + &__text { |
| 136 | + line-height: 1; |
138 | 137 | }
|
| 138 | + } |
139 | 139 |
|
140 |
| - &__right-info { |
141 |
| - color: $u-tips-color; |
142 |
| - font-size: 26rpx; |
143 |
| - display: flex; |
144 |
| - align-items: center; |
| 140 | + &__right-info { |
| 141 | + color: $u-tips-color; |
| 142 | + font-size: 26rpx; |
| 143 | + display: flex; |
| 144 | + align-items: center; |
145 | 145 |
|
146 |
| - &__icon-arrow { |
147 |
| - margin-left: 6rpx; |
148 |
| - } |
| 146 | + &__icon-arrow { |
| 147 | + margin-left: 6rpx; |
149 | 148 | }
|
150 | 149 | }
|
| 150 | +} |
151 | 151 | </style>
|
0 commit comments