1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
| <template>
| <!--本文件由FirstUI授权予四川政采招投标咨询有限公司(会员ID:1 6 3,营业执照号:9 1 5 10 13 13 320 06 193 K)专用,请尊重知识产权,勿私下传播,违者追究法律责任。-->
| <view :key="visible" class="fui-overflow__hidden-wrap"
| :class="{'fui-overflow__hidden':type==1,'fui-gradient__hidden':type==2 && !visible,'fui-text__nowrap':type==1 && rows==1}"
| :style="{width:width,height:type==1 || visible?'auto':height,paddingTop:type==2?padding[0]:'0',paddingRight:type==2?padding[1]:0,paddingBottom:type==2?(padding[2] || padding[0]):0,paddingLeft:type==2?(padding[3] || padding[1]):0,background:background,fontSize:size+'rpx',color:color,fontWeight:fontWeight,'-webkit-line-clamp':type==1?rows:'none',textOverflow:overflow,textAlign:align}"
| @tap="handleTap">
| <!-- #ifdef APP-NVUE -->
| <text :key="visible"
| :style="{width:width,height:type==1 || visible?'auto':height,fontSize:size+'rpx',color:color,fontWeight:fontWeight,lines:type==1?rows:0,textOverflow:overflow,textAlign:align}"
| v-if="text">{{text}}</text>
| <!-- #endif -->
| <!-- #ifndef APP-NVUE -->
| {{text}}
| <!-- #endif -->
| <slot></slot>
| <view class="fui-oh__gradient-wrap" :style="{background:getGradientBgColor}" v-if="type==2 && !visible"></view>
| </view>
| </template>
|
| <script>
| export default {
| name: "fui-overflow-hidden",
| emits: ['click'],
| props: {
| text: {
| type: String,
| default: ''
| },
| type: {
| type: [Number, String],
| default: 1
| },
| rows: {
| type: [Number, String],
| default: 1
| },
| width: {
| type: String,
| default: '100%'
| },
| height: {
| type: String,
| default: 'auto'
| },
| padding: {
| type: Array,
| default () {
| return ['0', '0']
| }
| },
| align: {
| type: String,
| default: 'left'
| },
| background: {
| type: String,
| default: 'transparent'
| },
| size: {
| type: [Number, String],
| default: 32
| },
| color: {
| type: String,
| default: '#333333'
| },
| fontWeight: {
| type: [Number, String],
| default: 'normal'
| },
| overflow: {
| type: String,
| default: 'ellipsis'
| },
| gradientColor: {
| type: String,
| default: '#FFFFFF'
| },
| visible: {
| type: Boolean,
| default: false
| },
| param: {
| type: [Number, String],
| default: 0
| }
| },
| computed: {
| getGradientBgColor() {
| // #ifdef APP-NVUE
| return `linear-gradient(to bottom, rgba(255,255,255,0), ${this.gradientColor})`
| // #endif
|
| // #ifndef APP-NVUE
| return `-webkit-linear-gradient(top, rgba(255,255,255,0), ${this.gradientColor})`
| // #endif
| }
| },
| methods: {
| handleTap(e) {
| this.$emit('click', {
| param: this.param
| })
| }
| }
| }
| </script>
|
| <style scoped>
| .fui-overflow__hidden-wrap {
| position: relative;
| /* #ifndef APP-NVUE */
| box-sizing: border-box;
| flex-shrink: 0;
| /* #endif */
| flex: 1;
| }
|
| .fui-overflow__hidden {
| /* #ifndef APP-NVUE */
| display: -webkit-box;
| word-break: break-all;
| white-space: normal;
| -webkit-box-orient: vertical;
| /* #endif */
| overflow: hidden;
| }
|
| .fui-gradient__hidden {
| /* #ifndef APP-NVUE */
| display: block;
| word-break: break-all;
| /* #endif */
| overflow: hidden;
| }
|
| /* #ifndef APP-NVUE */
| .fui-text__nowrap {
| display: inline-block !important;
| word-break: normal !important;
| white-space: nowrap !important;
| }
|
| /* #endif */
| .fui-oh__gradient-wrap {
| /* #ifndef APP-NVUE */
| width: 100%;
| z-index: 2;
| /* #endif */
| flex: 1;
| position: absolute;
| top: 0;
| left: 0;
| right: 0;
| bottom: 0;
| }
| </style>
|
|