@kengic/uni 0.5.1 → 0.5.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/dist/uni/uni-ui/uni-badge/uni-badge.vue +222 -219
  2. package/dist/uni/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +29 -29
  3. package/dist/uni/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +88 -88
  4. package/dist/uni/uni-ui/uni-calendar/calendar.js +936 -532
  5. package/dist/uni/uni-ui/uni-calendar/i18n/en.json +10 -10
  6. package/dist/uni/uni-ui/uni-calendar/i18n/index.js +8 -7
  7. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hans.json +10 -10
  8. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hant.json +10 -10
  9. package/dist/uni/uni-ui/uni-calendar/uni-calendar-item.vue +190 -168
  10. package/dist/uni/uni-ui/uni-calendar/uni-calendar.vue +459 -459
  11. package/dist/uni/uni-ui/uni-calendar/util.js +324 -340
  12. package/dist/uni/uni-ui/uni-card/uni-card.vue +8 -1
  13. package/dist/uni/uni-ui/uni-col/uni-col.vue +294 -287
  14. package/dist/uni/uni-ui/uni-collapse/uni-collapse.vue +139 -140
  15. package/dist/uni/uni-ui/uni-collapse-item/uni-collapse-item.vue +381 -378
  16. package/dist/uni/uni-ui/uni-combox/uni-combox.vue +280 -272
  17. package/dist/uni/uni-ui/uni-countdown/i18n/en.json +4 -4
  18. package/dist/uni/uni-ui/uni-countdown/i18n/index.js +8 -7
  19. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hans.json +4 -4
  20. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hant.json +4 -4
  21. package/dist/uni/uni-ui/uni-countdown/uni-countdown.vue +249 -257
  22. package/dist/uni/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +832 -813
  23. package/dist/uni/uni-ui/uni-data-picker/keypress.js +42 -42
  24. package/dist/uni/uni-ui/uni-data-picker/uni-data-picker.vue +535 -516
  25. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-picker.js +623 -618
  26. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +293 -288
  27. package/dist/uni/uni-ui/uni-data-select/uni-data-select.vue +495 -509
  28. package/dist/uni/uni-ui/uni-dateformat/date-format.js +181 -184
  29. package/dist/uni/uni-ui/uni-dateformat/uni-dateformat.vue +81 -82
  30. package/dist/uni/uni-ui/uni-datetime-picker/calendar-item.vue +176 -170
  31. package/dist/uni/uni-ui/uni-datetime-picker/calendar.vue +926 -920
  32. package/dist/uni/uni-ui/uni-datetime-picker/i18n/en.json +20 -20
  33. package/dist/uni/uni-ui/uni-datetime-picker/i18n/index.js +8 -7
  34. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +21 -21
  35. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +21 -21
  36. package/dist/uni/uni-ui/uni-datetime-picker/time-picker.vue +921 -926
  37. package/dist/uni/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1059 -1012
  38. package/dist/uni/uni-ui/uni-datetime-picker/util.js +366 -377
  39. package/dist/uni/uni-ui/uni-drawer/keypress.js +42 -42
  40. package/dist/uni/uni-ui/uni-drawer/uni-drawer.vue +176 -167
  41. package/dist/uni/uni-ui/uni-easyinput/common.js +40 -42
  42. package/dist/uni/uni-ui/uni-easyinput/uni-easyinput.vue +628 -547
  43. package/dist/uni/uni-ui/uni-fab/uni-fab.vue +507 -483
  44. package/dist/uni/uni-ui/uni-fav/i18n/en.json +2 -2
  45. package/dist/uni/uni-ui/uni-fav/i18n/index.js +8 -7
  46. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hans.json +2 -2
  47. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hant.json +2 -2
  48. package/dist/uni/uni-ui/uni-fav/uni-fav.vue +155 -147
  49. package/dist/uni/uni-ui/uni-file-picker/choose-and-upload-file.js +172 -198
  50. package/dist/uni/uni-ui/uni-file-picker/uni-file-picker.vue +636 -634
  51. package/dist/uni/uni-ui/uni-file-picker/upload-file.vue +294 -293
  52. package/dist/uni/uni-ui/uni-file-picker/upload-image.vue +267 -270
  53. package/dist/uni/uni-ui/uni-file-picker/utils.js +81 -82
  54. package/dist/uni/uni-ui/uni-forms/uni-forms.vue +360 -372
  55. package/dist/uni/uni-ui/uni-forms/utils.js +170 -174
  56. package/dist/uni/uni-ui/uni-forms/validate.js +447 -456
  57. package/dist/uni/uni-ui/uni-forms-item/uni-forms-item.vue +497 -497
  58. package/dist/uni/uni-ui/uni-goods-nav/i18n/en.json +4 -4
  59. package/dist/uni/uni-ui/uni-goods-nav/i18n/index.js +8 -7
  60. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hans.json +4 -4
  61. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hant.json +4 -4
  62. package/dist/uni/uni-ui/uni-goods-nav/uni-goods-nav.vue +238 -222
  63. package/dist/uni/uni-ui/uni-grid/uni-grid.vue +134 -134
  64. package/dist/uni/uni-ui/uni-grid-item/uni-grid-item.vue +121 -119
  65. package/dist/uni/uni-ui/uni-group/uni-group.vue +121 -121
  66. package/dist/uni/uni-ui/uni-icons/icons.js +1170 -1168
  67. package/dist/uni/uni-ui/uni-icons/uni-icons.vue +91 -86
  68. package/dist/uni/uni-ui/uni-icons/uniicons.css +166 -166
  69. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +129 -129
  70. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list.vue +352 -347
  71. package/dist/uni/uni-ui/uni-link/uni-link.vue +134 -119
  72. package/dist/uni/uni-ui/uni-list/uni-list.vue +119 -110
  73. package/dist/uni/uni-ui/uni-list/uni-refresh.vue +14 -14
  74. package/dist/uni/uni-ui/uni-list/uni-refresh.wxs +14 -14
  75. package/dist/uni/uni-ui/uni-list-ad/uni-list-ad.vue +101 -95
  76. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.scss +18 -18
  77. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.vue +602 -586
  78. package/dist/uni/uni-ui/uni-list-item/uni-list-item.vue +507 -503
  79. package/dist/uni/uni-ui/uni-load-more/i18n/en.json +3 -3
  80. package/dist/uni/uni-ui/uni-load-more/i18n/index.js +8 -7
  81. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hans.json +3 -3
  82. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hant.json +3 -3
  83. package/dist/uni/uni-ui/uni-load-more/uni-load-more.vue +402 -392
  84. package/dist/uni/uni-ui/uni-nav-bar/uni-nav-bar.vue +328 -330
  85. package/dist/uni/uni-ui/uni-nav-bar/uni-status-bar.vue +17 -17
  86. package/dist/uni/uni-ui/uni-notice-bar/uni-notice-bar.vue +422 -401
  87. package/dist/uni/uni-ui/uni-number-box/uni-number-box.vue +211 -205
  88. package/dist/uni/uni-ui/uni-pagination/i18n/en.json +3 -3
  89. package/dist/uni/uni-ui/uni-pagination/i18n/es.json +3 -3
  90. package/dist/uni/uni-ui/uni-pagination/i18n/fr.json +3 -3
  91. package/dist/uni/uni-ui/uni-pagination/i18n/index.js +12 -11
  92. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hans.json +3 -3
  93. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hant.json +3 -3
  94. package/dist/uni/uni-ui/uni-pagination/uni-pagination.vue +450 -433
  95. package/dist/uni/uni-ui/uni-popup/uni-popup.vue +404 -404
  96. package/dist/uni/uni-ui/uni-popup-dialog/keypress.js +42 -42
  97. package/dist/uni/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +1 -0
  98. package/dist/uni/uni-ui/uni-popup-message/uni-popup-message.vue +126 -125
  99. package/dist/uni/uni-ui/uni-popup-share/uni-popup-share.vue +172 -172
  100. package/dist/uni/uni-ui/uni-rate/uni-rate.vue +343 -347
  101. package/dist/uni/uni-ui/uni-row/uni-row.vue +180 -182
  102. package/dist/uni/uni-ui/uni-scss/changelog.md +11 -4
  103. package/dist/uni/uni-ui/uni-scss/package.json +73 -73
  104. package/dist/uni/uni-ui/uni-scss/readme.md +2 -1
  105. package/dist/uni/uni-ui/uni-scss/styles/setting/_border.scss +2 -2
  106. package/dist/uni/uni-ui/uni-scss/styles/setting/_color.scss +46 -47
  107. package/dist/uni/uni-ui/uni-scss/styles/setting/_radius.scss +49 -49
  108. package/dist/uni/uni-ui/uni-scss/styles/setting/_space.scss +52 -53
  109. package/dist/uni/uni-ui/uni-scss/styles/setting/_styles.scss +142 -147
  110. package/dist/uni/uni-ui/uni-scss/styles/setting/_text.scss +20 -20
  111. package/dist/uni/uni-ui/uni-scss/styles/setting/_variables.scss +111 -95
  112. package/dist/uni/uni-ui/uni-scss/styles/tools/functions.scss +28 -18
  113. package/dist/uni/uni-ui/uni-scss/theme.scss +10 -7
  114. package/dist/uni/uni-ui/uni-scss/variables.scss +42 -24
  115. package/dist/uni/uni-ui/uni-search-bar/i18n/en.json +3 -3
  116. package/dist/uni/uni-ui/uni-search-bar/i18n/index.js +8 -7
  117. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hans.json +2 -2
  118. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hant.json +2 -2
  119. package/dist/uni/uni-ui/uni-search-bar/uni-search-bar.vue +290 -281
  120. package/dist/uni/uni-ui/uni-section/uni-section.vue +149 -146
  121. package/dist/uni/uni-ui/uni-segmented-control/uni-segmented-control.vue +141 -131
  122. package/dist/uni/uni-ui/uni-steps/uni-steps.vue +255 -236
  123. package/dist/uni/uni-ui/uni-swipe-action/uni-swipe-action.vue +51 -51
  124. package/dist/uni/uni-ui/uni-swipe-action-item/bindingx.js +276 -282
  125. package/dist/uni/uni-ui/uni-swipe-action-item/isPC.js +10 -10
  126. package/dist/uni/uni-ui/uni-swipe-action-item/mpalipay.js +182 -187
  127. package/dist/uni/uni-ui/uni-swipe-action-item/mpother.js +235 -244
  128. package/dist/uni/uni-ui/uni-swipe-action-item/mpwxs.js +70 -75
  129. package/dist/uni/uni-ui/uni-swipe-action-item/render.js +238 -247
  130. package/dist/uni/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +387 -313
  131. package/dist/uni/uni-ui/uni-swipe-action-item/wx.wxs +206 -215
  132. package/dist/uni/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +241 -197
  133. package/dist/uni/uni-ui/uni-table/uni-table.vue +445 -447
  134. package/dist/uni/uni-ui/uni-tag/uni-tag.vue +234 -244
  135. package/dist/uni/uni-ui/uni-tbody/uni-tbody.vue +20 -23
  136. package/dist/uni/uni-ui/uni-td/uni-td.vue +79 -80
  137. package/dist/uni/uni-ui/uni-th/filter-dropdown.vue +510 -503
  138. package/dist/uni/uni-ui/uni-th/uni-th.vue +289 -273
  139. package/dist/uni/uni-ui/uni-thead/uni-thead.vue +115 -114
  140. package/dist/uni/uni-ui/uni-title/uni-title.vue +151 -154
  141. package/dist/uni/uni-ui/uni-tooltip/uni-tooltip.vue +55 -60
  142. package/dist/uni/uni-ui/uni-tr/table-checkbox.vue +162 -163
  143. package/dist/uni/uni-ui/uni-tr/uni-tr.vue +158 -157
  144. package/dist/uni/uni-ui/uni-transition/createAnimation.js +130 -113
  145. package/dist/uni/uni-ui/uni-transition/uni-transition.vue +274 -272
  146. package/package.json +1 -1
@@ -1,167 +1,170 @@
1
1
  <template>
2
- <view class="uni-section">
3
- <view class="uni-section-header" @click="onClick">
4
- <view class="uni-section-header__decoration" v-if="type" :class="type" />
5
- <slot v-else name="decoration"></slot>
2
+ <view class="uni-section">
3
+ <view class="uni-section-header" @click="onClick">
4
+ <view class="uni-section-header__decoration" v-if="type" :class="type" />
5
+ <slot v-else name="decoration"></slot>
6
6
 
7
- <view class="uni-section-header__content">
8
- <text :style="{'font-size':titleFontSize,'color':titleColor}" class="uni-section__content-title" :class="{'distraction':!subTitle}">{{ title }}</text>
9
- <text v-if="subTitle" :style="{'font-size':subTitleFontSize,'color':subTitleColor}" class="uni-section-header__content-sub">{{ subTitle }}</text>
10
- </view>
7
+ <view class="uni-section-header__content">
8
+ <text :style="{ 'font-size': titleFontSize, color: titleColor }" class="uni-section__content-title" :class="{ distraction: !subTitle }">{{
9
+ title
10
+ }}</text>
11
+ <text v-if="subTitle" :style="{ 'font-size': subTitleFontSize, color: subTitleColor }" class="uni-section-header__content-sub">{{
12
+ subTitle
13
+ }}</text>
14
+ </view>
11
15
 
12
- <view class="uni-section-header__slot-right">
13
- <slot name="right"></slot>
16
+ <view class="uni-section-header__slot-right">
17
+ <slot name="right"></slot>
18
+ </view>
14
19
  </view>
15
- </view>
16
20
 
17
- <view class="uni-section-content" :style="{padding: _padding}">
18
- <slot />
19
- </view>
20
- </view>
21
+ <view class="uni-section-content" :style="{ padding: _padding }">
22
+ <slot />
23
+ </view>
24
+ </view>
21
25
  </template>
22
26
 
23
27
  <script>
28
+ /**
29
+ * Section 标题栏
30
+ * @description 标题栏
31
+ * @property {String} type = [line|circle|square] 标题装饰类型
32
+ * @value line 竖线
33
+ * @value circle 圆形
34
+ * @value square 正方形
35
+ * @property {String} title 主标题
36
+ * @property {String} titleFontSize 主标题字体大小
37
+ * @property {String} titleColor 主标题字体颜色
38
+ * @property {String} subTitle 副标题
39
+ * @property {String} subTitleFontSize 副标题字体大小
40
+ * @property {String} subTitleColor 副标题字体颜色
41
+ * @property {String} padding 默认插槽 padding
42
+ */
24
43
 
25
- /**
26
- * Section 标题栏
27
- * @description 标题栏
28
- * @property {String} type = [line|circle|square] 标题装饰类型
29
- * @value line 竖线
30
- * @value circle 圆形
31
- * @value square 正方形
32
- * @property {String} title 主标题
33
- * @property {String} titleFontSize 主标题字体大小
34
- * @property {String} titleColor 主标题字体颜色
35
- * @property {String} subTitle 副标题
36
- * @property {String} subTitleFontSize 副标题字体大小
37
- * @property {String} subTitleColor 副标题字体颜色
38
- * @property {String} padding 默认插槽 padding
39
- */
40
-
41
- export default {
42
- name: 'UniSection',
43
- emits:['click'],
44
- props: {
45
- type: {
46
- type: String,
47
- default: ''
48
- },
49
- title: {
50
- type: String,
51
- required: true,
52
- default: ''
53
- },
54
- titleFontSize: {
55
- type: String,
56
- default: '14px'
57
- },
58
- titleColor:{
59
- type: String,
60
- default: '#333'
61
- },
62
- subTitle: {
63
- type: String,
64
- default: ''
65
- },
66
- subTitleFontSize: {
67
- type: String,
68
- default: '12px'
69
- },
70
- subTitleColor: {
71
- type: String,
72
- default: '#999'
73
- },
74
- padding: {
75
- type: [Boolean, String],
76
- default: false
77
- }
78
- },
79
- computed:{
80
- _padding(){
81
- if(typeof this.padding === 'string'){
82
- return this.padding
83
- }
44
+ export default {
45
+ name: 'UniSection',
46
+ emits: ['click'],
47
+ props: {
48
+ type: {
49
+ type: String,
50
+ default: '',
51
+ },
52
+ title: {
53
+ type: String,
54
+ required: true,
55
+ default: '',
56
+ },
57
+ titleFontSize: {
58
+ type: String,
59
+ default: '14px',
60
+ },
61
+ titleColor: {
62
+ type: String,
63
+ default: '#333',
64
+ },
65
+ subTitle: {
66
+ type: String,
67
+ default: '',
68
+ },
69
+ subTitleFontSize: {
70
+ type: String,
71
+ default: '12px',
72
+ },
73
+ subTitleColor: {
74
+ type: String,
75
+ default: '#999',
76
+ },
77
+ padding: {
78
+ type: [Boolean, String],
79
+ default: false,
80
+ },
81
+ },
82
+ computed: {
83
+ _padding() {
84
+ if (typeof this.padding === 'string') {
85
+ return this.padding;
86
+ }
84
87
 
85
- return this.padding?'10px':''
86
- }
87
- },
88
- watch: {
89
- title(newVal) {
90
- if (uni.report && newVal !== '') {
91
- uni.report('title', newVal)
92
- }
93
- }
94
- },
95
- methods: {
96
- onClick() {
97
- this.$emit('click')
98
- }
99
- }
100
- }
88
+ return this.padding ? '10px' : '';
89
+ },
90
+ },
91
+ watch: {
92
+ title(newVal) {
93
+ if (uni.report && newVal !== '') {
94
+ uni.report('title', newVal);
95
+ }
96
+ },
97
+ },
98
+ methods: {
99
+ onClick() {
100
+ this.$emit('click');
101
+ },
102
+ },
103
+ };
101
104
  </script>
102
- <style lang="scss" >
103
- $uni-primary: #2979ff !default;
105
+ <style lang="scss">
106
+ $uni-primary: #2979ff !default;
104
107
 
105
- .uni-section {
106
- background-color: #fff;
107
- .uni-section-header {
108
- position: relative;
109
- /* #ifndef APP-NVUE */
110
- display: flex;
111
- /* #endif */
112
- flex-direction: row;
113
- align-items: center;
114
- padding: 12px 10px;
115
- font-weight: normal;
108
+ .uni-section {
109
+ background-color: #fff;
110
+ .uni-section-header {
111
+ position: relative;
112
+ /* #ifndef APP-NVUE */
113
+ display: flex;
114
+ /* #endif */
115
+ flex-direction: row;
116
+ align-items: center;
117
+ padding: 12px 10px;
118
+ font-weight: normal;
116
119
 
117
- &__decoration{
118
- margin-right: 6px;
119
- background-color: $uni-primary;
120
- &.line {
121
- width: 4px;
122
- height: 12px;
123
- border-radius: 10px;
124
- }
120
+ &__decoration {
121
+ margin-right: 6px;
122
+ background-color: $uni-primary;
123
+ &.line {
124
+ width: 4px;
125
+ height: 12px;
126
+ border-radius: 10px;
127
+ }
125
128
 
126
- &.circle {
127
- width: 8px;
128
- height: 8px;
129
- border-top-right-radius: 50px;
130
- border-top-left-radius: 50px;
131
- border-bottom-left-radius: 50px;
132
- border-bottom-right-radius: 50px;
133
- }
129
+ &.circle {
130
+ width: 8px;
131
+ height: 8px;
132
+ border-top-right-radius: 50px;
133
+ border-top-left-radius: 50px;
134
+ border-bottom-left-radius: 50px;
135
+ border-bottom-right-radius: 50px;
136
+ }
134
137
 
135
- &.square {
136
- width: 8px;
137
- height: 8px;
138
- }
139
- }
138
+ &.square {
139
+ width: 8px;
140
+ height: 8px;
141
+ }
142
+ }
140
143
 
141
- &__content {
142
- /* #ifndef APP-NVUE */
143
- display: flex;
144
- /* #endif */
145
- flex-direction: column;
146
- flex: 1;
147
- color: #333;
144
+ &__content {
145
+ /* #ifndef APP-NVUE */
146
+ display: flex;
147
+ /* #endif */
148
+ flex-direction: column;
149
+ flex: 1;
150
+ color: #333;
148
151
 
149
- .distraction {
150
- flex-direction: row;
151
- align-items: center;
152
- }
153
- &-sub {
154
- margin-top: 2px;
155
- }
156
- }
152
+ .distraction {
153
+ flex-direction: row;
154
+ align-items: center;
155
+ }
156
+ &-sub {
157
+ margin-top: 2px;
158
+ }
159
+ }
157
160
 
158
- &__slot-right{
159
- font-size: 14px;
160
- }
161
- }
161
+ &__slot-right {
162
+ font-size: 14px;
163
+ }
164
+ }
162
165
 
163
- .uni-section-content{
164
- font-size: 14px;
166
+ .uni-section-content {
167
+ font-size: 14px;
168
+ }
165
169
  }
166
- }
167
170
  </style>
@@ -1,145 +1,155 @@
1
1
  <template>
2
- <view :class="[styleType === 'text'?'segmented-control--text' : 'segmented-control--button' ]"
3
- :style="{ borderColor: styleType === 'text' ? '' : activeColor }" class="segmented-control">
4
- <view v-for="(item, index) in values" :class="[ styleType === 'text' ? '': 'segmented-control__item--button',
5
- index === currentIndex&&styleType === 'button' ? 'segmented-control__item--button--active': '',
6
- index === 0&&styleType === 'button' ? 'segmented-control__item--button--first': '',
7
- index === values.length - 1&&styleType === 'button' ? 'segmented-control__item--button--last': '' ]" :key="index"
8
- :style="{ backgroundColor: index === currentIndex && styleType === 'button' ? activeColor : '',borderColor: index === currentIndex&&(styleType === 'text'||styleType === 'button')?activeColor:'#d9d9d9' }"
9
- class="segmented-control__item" @click="_onClick(index)">
10
- <view>
11
- <text :style="{color:
12
- index === currentIndex
13
- ? styleType === 'text'
14
- ? activeColor
15
- : '#fff'
16
- : styleType === 'text'
17
- ? '#000'
18
- : activeColor}" class="segmented-control__text" :class="styleType === 'text' && index === currentIndex ? 'segmented-control__item--text': ''">{{ item }}</text>
19
- </view>
20
-
21
- </view>
22
- </view>
2
+ <view
3
+ :class="[styleType === 'text' ? 'segmented-control--text' : 'segmented-control--button']"
4
+ :style="{ borderColor: styleType === 'text' ? '' : activeColor }"
5
+ class="segmented-control"
6
+ >
7
+ <view
8
+ v-for="(item, index) in values"
9
+ :class="[
10
+ styleType === 'text' ? '' : 'segmented-control__item--button',
11
+ index === currentIndex && styleType === 'button' ? 'segmented-control__item--button--active' : '',
12
+ index === 0 && styleType === 'button' ? 'segmented-control__item--button--first' : '',
13
+ index === values.length - 1 && styleType === 'button' ? 'segmented-control__item--button--last' : '',
14
+ ]"
15
+ :key="index"
16
+ :style="{
17
+ backgroundColor: index === currentIndex && styleType === 'button' ? activeColor : '',
18
+ borderColor: index === currentIndex && (styleType === 'text' || styleType === 'button') ? activeColor : '#d9d9d9',
19
+ }"
20
+ class="segmented-control__item"
21
+ @click="_onClick(index)"
22
+ >
23
+ <view>
24
+ <text
25
+ :style="{ color: index === currentIndex ? (styleType === 'text' ? activeColor : '#fff') : styleType === 'text' ? '#000' : activeColor }"
26
+ class="segmented-control__text"
27
+ :class="styleType === 'text' && index === currentIndex ? 'segmented-control__item--text' : ''"
28
+ >{{ item }}</text
29
+ >
30
+ </view>
31
+ </view>
32
+ </view>
23
33
  </template>
24
34
 
25
35
  <script>
26
- /**
27
- * SegmentedControl 分段器
28
- * @description 用作不同视图的显示
29
- * @tutorial https://ext.dcloud.net.cn/plugin?id=54
30
- * @property {Number} current 当前选中的tab索引值,从0计数
31
- * @property {String} styleType = [button|text] 分段器样式类型
32
- * @value button 按钮类型
33
- * @value text 文字类型
34
- * @property {String} activeColor 选中的标签背景色与边框颜色
35
- * @property {Array} values 选项数组
36
- * @event {Function} clickItem 组件触发点击事件时触发,e={currentIndex}
37
- */
36
+ /**
37
+ * SegmentedControl 分段器
38
+ * @description 用作不同视图的显示
39
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=54
40
+ * @property {Number} current 当前选中的tab索引值,从0计数
41
+ * @property {String} styleType = [button|text] 分段器样式类型
42
+ * @value button 按钮类型
43
+ * @value text 文字类型
44
+ * @property {String} activeColor 选中的标签背景色与边框颜色
45
+ * @property {Array} values 选项数组
46
+ * @event {Function} clickItem 组件触发点击事件时触发,e={currentIndex}
47
+ */
38
48
 
39
- export default {
40
- name: 'UniSegmentedControl',
41
- emits: ['clickItem'],
42
- props: {
43
- current: {
44
- type: Number,
45
- default: 0
46
- },
47
- values: {
48
- type: Array,
49
- default () {
50
- return []
51
- }
52
- },
53
- activeColor: {
54
- type: String,
55
- default: '#2979FF'
56
- },
57
- styleType: {
58
- type: String,
59
- default: 'button'
60
- }
61
- },
62
- data() {
63
- return {
64
- currentIndex: 0
65
- }
66
- },
67
- watch: {
68
- current(val) {
69
- if (val !== this.currentIndex) {
70
- this.currentIndex = val
71
- }
72
- }
73
- },
74
- created() {
75
- this.currentIndex = this.current
76
- },
77
- methods: {
78
- _onClick(index) {
79
- if (this.currentIndex !== index) {
80
- this.currentIndex = index
81
- this.$emit('clickItem', {
82
- currentIndex: index
83
- })
84
- }
85
- }
86
- }
87
- }
49
+ export default {
50
+ name: 'UniSegmentedControl',
51
+ emits: ['clickItem'],
52
+ props: {
53
+ current: {
54
+ type: Number,
55
+ default: 0,
56
+ },
57
+ values: {
58
+ type: Array,
59
+ default() {
60
+ return [];
61
+ },
62
+ },
63
+ activeColor: {
64
+ type: String,
65
+ default: '#2979FF',
66
+ },
67
+ styleType: {
68
+ type: String,
69
+ default: 'button',
70
+ },
71
+ },
72
+ data() {
73
+ return {
74
+ currentIndex: 0,
75
+ };
76
+ },
77
+ watch: {
78
+ current(val) {
79
+ if (val !== this.currentIndex) {
80
+ this.currentIndex = val;
81
+ }
82
+ },
83
+ },
84
+ created() {
85
+ this.currentIndex = this.current;
86
+ },
87
+ methods: {
88
+ _onClick(index) {
89
+ if (this.currentIndex !== index) {
90
+ this.currentIndex = index;
91
+ this.$emit('clickItem', {
92
+ currentIndex: index,
93
+ });
94
+ }
95
+ },
96
+ },
97
+ };
88
98
  </script>
89
99
 
90
- <style lang="scss" >
91
- .segmented-control {
92
- /* #ifndef APP-NVUE */
93
- display: flex;
94
- box-sizing: border-box;
95
- /* #endif */
96
- flex-direction: row;
97
- height: 36px;
98
- overflow: hidden;
99
- /* #ifdef H5 */
100
- cursor: pointer;
101
- /* #endif */
102
- }
100
+ <style lang="scss">
101
+ .segmented-control {
102
+ /* #ifndef APP-NVUE */
103
+ display: flex;
104
+ box-sizing: border-box;
105
+ /* #endif */
106
+ flex-direction: row;
107
+ height: 36px;
108
+ overflow: hidden;
109
+ /* #ifdef H5 */
110
+ cursor: pointer;
111
+ /* #endif */
112
+ }
103
113
 
104
- .segmented-control__item {
105
- /* #ifndef APP-NVUE */
106
- display: inline-flex;
107
- box-sizing: border-box;
108
- /* #endif */
109
- position: relative;
110
- flex: 1;
111
- justify-content: center;
112
- align-items: center;
113
- }
114
+ .segmented-control__item {
115
+ /* #ifndef APP-NVUE */
116
+ display: inline-flex;
117
+ box-sizing: border-box;
118
+ /* #endif */
119
+ position: relative;
120
+ flex: 1;
121
+ justify-content: center;
122
+ align-items: center;
123
+ }
114
124
 
115
- .segmented-control__item--button {
116
- border-style: solid;
117
- border-top-width: 1px;
118
- border-bottom-width: 1px;
119
- border-right-width: 1px;
120
- border-left-width: 0;
121
- }
125
+ .segmented-control__item--button {
126
+ border-style: solid;
127
+ border-top-width: 1px;
128
+ border-bottom-width: 1px;
129
+ border-right-width: 1px;
130
+ border-left-width: 0;
131
+ }
122
132
 
123
- .segmented-control__item--button--first {
124
- border-left-width: 1px;
125
- border-top-left-radius: 5px;
126
- border-bottom-left-radius: 5px;
127
- }
133
+ .segmented-control__item--button--first {
134
+ border-left-width: 1px;
135
+ border-top-left-radius: 5px;
136
+ border-bottom-left-radius: 5px;
137
+ }
128
138
 
129
- .segmented-control__item--button--last {
130
- border-top-right-radius: 5px;
131
- border-bottom-right-radius: 5px;
132
- }
139
+ .segmented-control__item--button--last {
140
+ border-top-right-radius: 5px;
141
+ border-bottom-right-radius: 5px;
142
+ }
133
143
 
134
- .segmented-control__item--text {
135
- border-bottom-style: solid;
136
- border-bottom-width: 2px;
137
- padding: 6px 0;
138
- }
144
+ .segmented-control__item--text {
145
+ border-bottom-style: solid;
146
+ border-bottom-width: 2px;
147
+ padding: 6px 0;
148
+ }
139
149
 
140
- .segmented-control__text {
141
- font-size: 14px;
142
- line-height: 20px;
143
- text-align: center;
144
- }
150
+ .segmented-control__text {
151
+ font-size: 14px;
152
+ line-height: 20px;
153
+ text-align: center;
154
+ }
145
155
  </style>