fusions-ui 1.2.4 → 1.2.7

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 (176) hide show
  1. package/components/fu-avatar/fu-avatar.vue +4 -2
  2. package/components/fu-avatar/props.js +52 -15
  3. package/components/fu-avatar-group/fu-avatar-group.vue +3 -2
  4. package/components/fu-avatar-group/props.js +31 -9
  5. package/components/fu-badge/fu-badge.vue +8 -14
  6. package/components/fu-badge/props.js +56 -16
  7. package/components/fu-banner-arc/fu-banner-arc.vue +4 -5
  8. package/components/fu-banner-arc/props.js +15 -4
  9. package/components/fu-button/fu-button.vue +18 -20
  10. package/components/fu-button/props.js +108 -35
  11. package/components/fu-cell/fu-cell.vue +9 -8
  12. package/components/fu-cell-group/fu-cell-group.vue +2 -1
  13. package/components/fu-cell-group/props.js +7 -2
  14. package/components/fu-checkbox/fu-checkbox.vue +5 -4
  15. package/components/fu-checkbox/props.js +51 -14
  16. package/components/fu-code-input/fu-code-input.vue +10 -6
  17. package/components/fu-code-input/props.js +66 -17
  18. package/components/fu-code-verify/fu-code-verify.vue +9 -5
  19. package/components/fu-code-verify/props.js +64 -17
  20. package/components/fu-collapse/fu-collapse.vue +10 -3
  21. package/components/fu-collapse/props.js +9 -3
  22. package/components/fu-collapse-item/fu-collapse-item.vue +45 -31
  23. package/components/fu-collapse-item/props.js +49 -16
  24. package/components/fu-countdown/fu-countdown.vue +2 -1
  25. package/components/fu-countdown/props.js +15 -4
  26. package/components/fu-datetime-picker/fu-datetime-picker.vue +6 -5
  27. package/components/fu-datetime-picker/props.js +91 -25
  28. package/components/fu-form/fu-form.vue +2 -1
  29. package/components/fu-form/props.js +34 -6
  30. package/components/fu-form-item/fu-form-item.vue +26 -33
  31. package/components/fu-form-item/props.js +30 -8
  32. package/components/fu-grid/fu-grid.vue +16 -17
  33. package/components/fu-grid/props.js +20 -5
  34. package/components/fu-grid-item/fu-grid-item.vue +31 -35
  35. package/components/fu-grid-item/props.js +11 -3
  36. package/components/fu-icon/fu-icon.vue +110 -0
  37. package/components/fu-icon/fuicon.css +584 -0
  38. package/components/{fu-icons/icons.js → fu-icon/fuicon.js} +1031 -1031
  39. package/components/{fu-icons/fuicons.ttf → fu-icon/fuicon.ttf} +0 -0
  40. package/components/fu-icon/props.js +55 -0
  41. package/components/fu-image/fu-image.vue +15 -10
  42. package/components/fu-image/props.js +69 -18
  43. package/components/fu-index-anchor/fu-index-anchor.vue +6 -5
  44. package/components/fu-index-anchor/props.js +20 -6
  45. package/components/fu-index-item/fu-index-item.vue +4 -4
  46. package/components/fu-index-list/fu-index-list.vue +9 -9
  47. package/components/fu-index-list/props.js +19 -6
  48. package/components/fu-input/fu-input.vue +54 -68
  49. package/components/fu-input/props.js +145 -53
  50. package/components/fu-keyboard/fu-keyboard.vue +19 -9
  51. package/components/fu-keyboard/keyboard-car.vue +33 -22
  52. package/components/fu-keyboard/keyboard-number.vue +17 -9
  53. package/components/fu-keyboard/props.js +66 -17
  54. package/components/fu-line/fu-line.vue +17 -13
  55. package/components/fu-line/props.js +30 -5
  56. package/components/fu-link/fu-link.vue +14 -8
  57. package/components/fu-link/props.js +22 -7
  58. package/components/fu-loading/fu-loading.vue +32 -27
  59. package/components/fu-loading/props.js +28 -8
  60. package/components/fu-loading-more/fu-loading-more.vue +19 -23
  61. package/components/fu-loading-more/props.js +27 -13
  62. package/components/fu-modal/fu-modal.vue +11 -6
  63. package/components/fu-modal/props.js +61 -17
  64. package/components/{fu-nav-bar/fu-nav-bar.vue → fu-navbar/fu-navbar.vue} +37 -44
  65. package/components/fu-notice-bar/fu-notice-bar.vue +10 -8
  66. package/components/fu-notice-bar/notice-column.vue +187 -122
  67. package/components/fu-notice-bar/notice-row.vue +85 -28
  68. package/components/fu-notice-bar/props.js +83 -22
  69. package/components/fu-number-box/fu-number-box.vue +26 -28
  70. package/components/fu-number-box/props.js +37 -11
  71. package/components/fu-parse/fu-parse.vue +0 -1
  72. package/components/fu-picker/fu-picker.vue +22 -17
  73. package/components/fu-picker/props.js +70 -19
  74. package/components/fu-popup/fu-popup.vue +38 -43
  75. package/components/fu-popup/props.js +34 -9
  76. package/components/fu-progress/fu-progress.vue +3 -2
  77. package/components/fu-progress/props.js +36 -9
  78. package/components/fu-rate/fu-rate.vue +40 -32
  79. package/components/fu-rate/props.js +47 -13
  80. package/components/fu-read-more/fu-read-more.vue +19 -14
  81. package/components/fu-read-more/props.js +68 -46
  82. package/components/fu-ribbon/fu-ribbon.vue +8 -7
  83. package/components/fu-ribbon/props.js +15 -4
  84. package/components/fu-scroll-list/fu-scroll-list.vue +18 -34
  85. package/components/fu-scroll-list/props.js +19 -10
  86. package/components/fu-search/fu-search.vue +13 -18
  87. package/components/fu-search/props.js +69 -17
  88. package/components/fu-section/fu-section.vue +19 -22
  89. package/components/fu-section/props.js +30 -4
  90. package/components/fu-sign-board/fu-sign-board.vue +34 -17
  91. package/components/fu-sign-board/props.js +15 -5
  92. package/components/fu-skeleton/fu-skeleton.vue +8 -12
  93. package/components/fu-skeleton/props.js +15 -4
  94. package/components/fu-steps/fu-steps.vue +3 -2
  95. package/components/fu-steps/props.js +23 -7
  96. package/components/fu-steps-item/fu-steps-item.vue +3 -3
  97. package/components/fu-steps-item/props.js +15 -5
  98. package/components/fu-sticky/fu-sticky.vue +3 -3
  99. package/components/fu-sticky/props.js +21 -7
  100. package/components/fu-subsection/fu-subsection.vue +29 -22
  101. package/components/fu-subsection/props.js +40 -10
  102. package/components/fu-swipe-action-item/bindingx.js +1 -1
  103. package/components/fu-swipe-action-item/fu-swipe-action-item.vue +134 -123
  104. package/components/fu-swipe-action-item/mpwxs.js +1 -1
  105. package/components/fu-swipe-action-item/props.js +22 -6
  106. package/components/fu-swiper/fu-swiper.vue +29 -27
  107. package/components/fu-swiper/props.js +81 -25
  108. package/components/fu-switch/fu-switch.vue +20 -12
  109. package/components/fu-switch/props.js +48 -13
  110. package/components/fu-tabs/fu-tabs.vue +36 -33
  111. package/components/fu-tabs/props.js +46 -13
  112. package/components/fu-tag/fu-tag.vue +24 -21
  113. package/components/fu-tag/props.js +63 -17
  114. package/components/fu-text/fu-text.vue +72 -33
  115. package/components/fu-text/props.js +85 -27
  116. package/components/fu-text/value.js +6 -6
  117. package/components/fu-textarea/fu-textarea.vue +13 -17
  118. package/components/fu-textarea/props.js +103 -30
  119. package/components/fu-timeaxis/fu-timeaxis.vue +1 -1
  120. package/components/fu-timeaxis-item/fu-timeaxis-item.vue +8 -4
  121. package/components/fu-transition/fu-transition.vue +48 -49
  122. package/components/fu-transition/props.js +21 -0
  123. package/components/fu-upload/fu-upload.vue +3 -1
  124. package/components/fu-upload/props.js +67 -19
  125. package/components/fu-upload/upload-file.vue +31 -18
  126. package/components/fu-upload/upload-image.vue +37 -19
  127. package/components/fu-vtabs/fu-vtabs.vue +6 -4
  128. package/components/fu-vtabs/props.js +50 -15
  129. package/components/fu-waterfall/fu-waterfall.vue +11 -9
  130. package/components/fu-waterfall/props.js +37 -15
  131. package/index.js +17 -24
  132. package/index.scss +9 -7
  133. package/libs/config/config.js +16 -9
  134. package/libs/function/applyEven.js +9 -9
  135. package/libs/function/check.js +81 -89
  136. package/libs/function/{index.js → common.js} +5 -5
  137. package/libs/function/message.js +0 -27
  138. package/libs/mixin/mixin.js +26 -21
  139. package/libs/{utils/min.router.config.js → route/min.route.config.js} +7 -7
  140. package/libs/{utils/router.config.js → route/route.config.js} +10 -11
  141. package/libs/{css/main.scss → style/common.scss} +50 -87
  142. package/libs/style/style.h5.scss +8 -0
  143. package/libs/style/style.mp.scss +15 -0
  144. package/package.json +1 -1
  145. package/components/fu-calendar/calendar-item.vue +0 -214
  146. package/components/fu-calendar/calendar.js +0 -546
  147. package/components/fu-calendar/fu-calendar.vue +0 -536
  148. package/components/fu-calendar/i18n/en.json +0 -12
  149. package/components/fu-calendar/i18n/index.js +0 -8
  150. package/components/fu-calendar/i18n/zh-Hans.json +0 -12
  151. package/components/fu-calendar/i18n/zh-Hant.json +0 -12
  152. package/components/fu-calendar/util.js +0 -360
  153. package/components/fu-date-picker/calendar-item.vue +0 -177
  154. package/components/fu-date-picker/calendar.vue +0 -917
  155. package/components/fu-date-picker/fu-date-picker.vue +0 -1069
  156. package/components/fu-date-picker/i18n/en.json +0 -22
  157. package/components/fu-date-picker/i18n/index.js +0 -8
  158. package/components/fu-date-picker/i18n/zh-Hans.json +0 -22
  159. package/components/fu-date-picker/i18n/zh-Hant.json +0 -22
  160. package/components/fu-date-picker/props.js +0 -68
  161. package/components/fu-date-picker/time-picker.vue +0 -924
  162. package/components/fu-date-picker/util.js +0 -419
  163. package/components/fu-icons/fu-icons.vue +0 -102
  164. package/components/fu-icons/fuicons.css +0 -585
  165. package/components/fu-landscape/fu-landscape.vue +0 -167
  166. package/components/fu-landscape/props.js +0 -64
  167. package/components/fu-tabbar/fu-tabbar.vue +0 -333
  168. package/components/fu-tabbar/props.js +0 -78
  169. package/libs/css/style.h5.scss +0 -35
  170. package/libs/css/style.mp.scss +0 -50
  171. package/libs/utils/util.js +0 -58
  172. /package/components/{fu-nav-bar → fu-navbar}/props.js +0 -0
  173. /package/components/{fu-nav-bar → fu-navbar}/status-bar.vue +0 -0
  174. /package/{components/fu-datetime-picker → libs/function}/dayjs.js +0 -0
  175. /package/libs/{css → style}/color.scss +0 -0
  176. /package/libs/{css/component.scss → style/components.scss} +0 -0
@@ -1,104 +1,160 @@
1
1
  export default {
2
2
  props: {
3
- // 轮播图列表数据
4
- // [{image: xxx.jpg, title: 'xxxx'}] ['xxxx', 'xxxx', 'xxxx']
3
+ /**
4
+ * @description 轮播图列表数据 如:[{image: xxx.jpg, title: 'xxxx'}] ['xxxx', 'xxxx', 'xxxx']
5
+ */
5
6
  list: {
6
7
  type: Array,
7
8
  default: () => []
8
9
  },
9
- // 圆角的值
10
+ /**
11
+ * @description 设置圆角
12
+ * @default 5
13
+ */
10
14
  radius: {
11
15
  type: [String, Number],
12
16
  default: 5
13
17
  },
14
- // 初始化时,默认显示第几项
18
+ /**
19
+ * @description 初始化时,默认显示第几项
20
+ */
15
21
  current: {
16
22
  type: Number,
17
23
  default: 0
18
24
  },
19
- // 高度
25
+ /**
26
+ * @description 设置高度
27
+ * @default 160
28
+ */
20
29
  height: {
21
30
  type: [String, Number],
22
- default: 125
31
+ default: 160
23
32
  },
24
- // 背景色
33
+ /**
34
+ * @description 背景颜色
35
+ * @default '#f2f3f4'
36
+ */
25
37
  bgColor: {
26
38
  type: String,
27
39
  default: '#f2f3f4'
28
40
  },
29
- // 图片的属性名
30
- nameKey: {
41
+ /**
42
+ * @description 图片的属性名
43
+ * @default 'image'
44
+ */
45
+ keyName: {
31
46
  type: String,
32
47
  default: 'image'
33
48
  },
34
- // 是否显示标题
49
+ /**
50
+ * @description 是否显示标题
51
+ * @default false
52
+ */
35
53
  showTitle: {
36
54
  type: Boolean,
37
55
  default: false
38
56
  },
39
- // 标题的属性名
57
+ /**
58
+ * @description 是否显示标题
59
+ * @default 'title'
60
+ */
40
61
  keyTitle: {
41
62
  type: String,
42
63
  default: 'title'
43
64
  },
44
- // 自定义标题样式
65
+ /**
66
+ * @description 定义需要用到的外部标题样式
67
+ */
45
68
  titleStyle: {
46
69
  type: Object,
47
70
  default: () => {}
48
71
  },
49
- // 指示器模式
50
- // rect: 方形; round: 圆角方形; dot: 点; number: 轮播图下标
72
+ /**
73
+ * @description 指示器模式
74
+ * @values 'rect' - 方形, 'round' - 圆角方形, 'dot' - 点, 'number' - 轮播图下标
75
+ * @default 'round'
76
+ */
51
77
  mode: {
52
78
  type: String,
53
79
  default: 'round'
54
80
  },
55
- // 是否显示指示灯(默认 true)
81
+ /**
82
+ * @description 是否显示指示灯
83
+ * @default true
84
+ */
56
85
  indicator: {
57
86
  type: Boolean,
58
87
  default: true
59
88
  },
60
- // 指示器位置
61
- // topLeft \ topCenter \ topRight \ bottomLeft \ bottomCenter \ bottomRight
89
+ /**
90
+ * @description 指示器位置
91
+ * @values 'topLeft' - 指示器位于左上角, 'topCenter' - 指示器位于上方中间位置, 'topRight' - 指示器位于右上角, 'bottomLeft' - 指示器位于左下角, 'bottomCenter' - 指示器位于底部中间位置, 'bottomRight' - 指示器位于右下角
92
+ * @default 'bottomCenter'
93
+ */
62
94
  indicatorPosition: {
63
95
  type: String,
64
96
  default: 'bottomCenter'
65
97
  },
66
- // 开启3D缩放效果
98
+ /**
99
+ * @description 开启3D缩放效果
100
+ * @default false
101
+ */
67
102
  effect3D: {
68
103
  type: Boolean,
69
104
  default: false
70
105
  },
71
- // 在3D缩放模式下,item之间的间隔
106
+ /**
107
+ * @description 在3D缩放模式下,item之间的间隔
108
+ * @default 25
109
+ */
72
110
  effect3DPreviousSpacing: {
73
111
  type: [String, Number],
74
112
  default: 25
75
113
  },
76
- // 自定播放
114
+ /**
115
+ * @description 自动播放
116
+ * @default true
117
+ */
77
118
  autoplay: {
78
119
  type: Boolean,
79
120
  default: true
80
121
  },
81
- // 图片之间播放间隔多久
122
+ /**
123
+ * @description 图片之间播放间隔多久
124
+ * @default 3000
125
+ */
82
126
  interval: {
83
127
  type: Number,
84
128
  default: 3000
85
129
  },
86
- // 轮播间隔时间
130
+ /**
131
+ * @description 轮播间隔时间
132
+ * @default 500
133
+ */
87
134
  duration: {
88
135
  type: Number,
89
136
  default: 500
90
137
  },
91
- // 是否衔接滑动
138
+ /**
139
+ * @description 是否衔接滑动
140
+ * @default true
141
+ */
92
142
  circular: {
93
143
  type: Boolean,
94
144
  default: true
95
145
  },
96
- // 图片裁剪模式
146
+ /**
147
+ * @description 图片裁剪模式
148
+ * @default 'aspectFill'
149
+ */
97
150
  imgMode: {
98
151
  type: String,
99
152
  default: 'aspectFill'
100
153
  },
101
- // 是否加载中
154
+ /**
155
+ * @description 是否加载中
156
+ * @default false
157
+ */
102
158
  loading: {
103
159
  type: Boolean,
104
160
  default: false
@@ -1,7 +1,12 @@
1
1
  <template>
2
- <view class="fu-switch" :class="[innerValue? 'fu-switch__on': '', disabled? 'fu-switch__disabled': '', `fu-switch__${shape}`]" :style="[switchStyle]" @tap="click">
2
+ <view class="fu-switch" :class="[innerValue? 'fu-switch__on': '', disabled? 'fu-switch__disabled': '', `fu-switch__${shape}`]" :style="[switchStyle]" @tap="handleClick">
3
3
  <view class="fu-switch__node" :class="[`fu-switch__node__${shape}`]" :style="[switchNodeStyle]">
4
- <fu-loading class="fu-switch__node__loading" :show="loading" mode="circle" :size="size * 0.6" :color="loadingColor"></fu-loading>
4
+ <fu-loading
5
+ :show="loading"
6
+ mode="circle"
7
+ :size="size * 0.6"
8
+ :color="innerValue? activeColor: '#a8a9ab'">
9
+ </fu-loading>
5
10
  </view>
6
11
 
7
12
  <!-- 左图标 -->
@@ -19,19 +24,22 @@
19
24
  * Switch 开关选择器
20
25
  * @description 此组件选择开关一般用于只有两个选择,且只能选其一的场景。
21
26
  * @property {Boolean,String,Number} value 通过v-model双向绑定的值 (默认 false )
22
- * @property {String} shape = [circle|square] circle 圆角 square 方形 (默认 circle)
27
+ * @property {String} shape = [circle|square] 设置形状(默认 'circle')
28
+ * @value circle 圆角
29
+ * @value square 方形
23
30
  * @property {Boolean} disabled = [true|false] 是否禁用(默认 false)
24
31
  * @property {String,Number} size 尺寸(默认 20)
25
- * @property {String} activeColor 打开时的背景颜色
26
- * @property {String} inactiveColor 关闭时的背景颜色
32
+ * @property {String} activeColor 打开时的背景颜色(默认 '#2979ff')
33
+ * @property {String} inactiveColor 关闭时的背景颜色(默认 '#d6d6d6')
27
34
  * @property {Number,String,Boolean} activeValue 激活时的值 (默认 true)
28
35
  * @property {Number,String,Boolean} inactiveValue 关闭时的值(默认false)
29
36
  * @property {String} leftIcon 左图标
30
37
  * @property {String} rightIcon 右图标
31
38
  * @property {Boolean} loading = [true|false] 是否为加载状态
32
39
  * @property {Boolean} vibrateShort = [true|false] 点击手机是否震动(默认 false)
40
+ *
33
41
  * @event {Function} change 在switch打开或关闭时触发
34
- * @example <fu-switch v-model="checked" activeColor="red" inactiveColor="#eeeeee" />
42
+ * @example <fu-switch v-model="checked"></fu-switch>
35
43
  */
36
44
  export default {
37
45
  name: 'FuSwitch',
@@ -46,10 +54,13 @@
46
54
  this.innerValue = this.value || this.modelValue;
47
55
  },
48
56
  computed: {
57
+ isActive() {
58
+ return this.innerValue === this.activeValue;
59
+ },
49
60
  switchStyle() {
50
61
  let style = {};
51
62
  style.fontSize = this.$fu.addUnit(this.size);
52
- style.backgroundColor = this.innerValue? this.activeColor? this.activeColor: '#2979ff' : this.inactiveColor? this.inactiveColor : '#d6d6d6';
63
+ style.backgroundColor = this.isActive? this.activeColor: this.inactiveColor;
53
64
  return style
54
65
  },
55
66
 
@@ -65,16 +76,13 @@
65
76
  style.fontSize = this.$fu.addUnit(this.size - 20)
66
77
  style.lineHeight = this.$fu.addUnit(this.size)
67
78
  return style
68
- },
69
- loadingColor() {
70
- return this.innerValue ? this.activeColor || '#2979ff' : ''
71
79
  }
72
80
  },
73
81
  methods: {
74
- click() {
82
+ handleClick() {
75
83
  if (!this.disabled && !this.loading) {
76
84
  if (this.vibrateShort) uni.vibrateShort()
77
- const oldVal = this.innerValue? this.activeValue : this.inactiveValue;
85
+ const oldVal = this.isActive? this.inactiveValue: this.activeValue;
78
86
  this.$emit('input', oldVal)
79
87
  this.$emit('update:modelValue', oldVal)
80
88
  // 放到下一个生命周期,因为双向绑定的value修改父组件状态需要时间,且是异步的
@@ -1,5 +1,8 @@
1
1
  export default {
2
2
  props: {
3
+ /**
4
+ * @description value / v-model 绑定的值
5
+ */
3
6
  value: {
4
7
  type: [Boolean,String,Number],
5
8
  default: false
@@ -8,57 +11,89 @@ export default {
8
11
  type: [Boolean,String,Number],
9
12
  default: false
10
13
  },
11
- // circle 圆角 square 方形
14
+ /**
15
+ * @description 设置形状
16
+ * @values 'circle' - 圆角, 'square' - 方形
17
+ * @default 'circle'
18
+ */
12
19
  shape: {
13
20
  type: String,
14
21
  default: 'circle'
15
22
  },
16
- // 是否禁用
23
+ /**
24
+ * @description 是否禁用
25
+ * @default false
26
+ */
17
27
  disabled: {
18
28
  type: Boolean,
19
29
  default: false
20
30
  },
21
- // 尺寸
31
+ /**
32
+ * @description 设置尺寸
33
+ * @default 20
34
+ */
22
35
  size: {
23
36
  type: [String,Number],
24
37
  default: 20
25
38
  },
26
- // 打开时的背景颜色
39
+ /**
40
+ * @description 打开时的背景颜色
41
+ * @default '#2979ff'
42
+ */
27
43
  activeColor: {
28
44
  type: String,
29
- default: ''
45
+ default: '#2979ff'
30
46
  },
31
- // 关闭时的背景颜色
47
+ /**
48
+ * @description 关闭时的背景颜色
49
+ * @default '#d6d6d6'
50
+ */
32
51
  inactiveColor: {
33
52
  type: String,
34
- default: ''
53
+ default: '#d6d6d6'
35
54
  },
36
- // 激活时的值
55
+ /**
56
+ * @description 激活时的值
57
+ * @default true
58
+ */
37
59
  activeValue: {
38
60
  type: [Number,String,Boolean],
39
61
  default: true
40
62
  },
41
- // 关闭时的值
63
+ /**
64
+ * @description 关闭时的值
65
+ * @default false
66
+ */
42
67
  inactiveValue: {
43
68
  type: [Number,String,Boolean],
44
69
  default: false
45
70
  },
46
- // 左图标
71
+ /**
72
+ * @description 左图标
73
+ */
47
74
  leftIcon: {
48
75
  type: String,
49
76
  default: ''
50
77
  },
51
- // 右图标
78
+ /**
79
+ * @description 右图标
80
+ */
52
81
  rightIcon: {
53
82
  type: String,
54
83
  default: ''
55
84
  },
56
- // 是否为加载状态
85
+ /**
86
+ * @description 是否为加载状态
87
+ * @default false
88
+ */
57
89
  loading: {
58
90
  type: Boolean,
59
91
  default: false
60
92
  },
61
- // 点击手机是否震动
93
+ /**
94
+ * @description 点击手机是否震动
95
+ * @default false
96
+ */
62
97
  vibrateShort: {
63
98
  type: Boolean,
64
99
  default: false
@@ -6,7 +6,7 @@
6
6
  <scroll-view ref="fu-tabs__wrapper__scroll-view" class="fu-tabs__wrapper__scroll-view" :scroll-x="scrollable" :scroll-left="scrollLeft" scroll-with-animation :show-scrollbar="false">
7
7
  <view ref="fu-tabs__wrapper__nav" class="fu-tabs__wrapper__nav" :style="{flex: scrollable ? '' : 1}">
8
8
  <view :ref="`fu-tabs__wrapper__nav__item-${index}`" class="fu-tabs__wrapper__nav__item" :class="[`fu-tabs__wrapper__nav__item-${index}`, item.disabled && 'fu-tabs__wrapper__nav__item--disabled']"
9
- :style="[{flex: scrollable ? '' : 1, padding}, itemStyle]" v-for="(item, index) in list" :key="index" @tap="clickHandler(item, index)">
9
+ :style="[{flex: scrollable ? '' : 1, padding}, itemStyle]" v-for="(item, index) in list" :key="index" @tap="handleClick(item, index)">
10
10
  <text class="fu-tabs__wrapper__nav__item__text" :class="[item.disabled && 'fu-tabs__wrapper__nav__item__text--disabled']" :style="[textStyle(index)]">{{ item[keyName] }}</text>
11
11
 
12
12
  <!-- 徽标 -->
@@ -27,27 +27,7 @@
27
27
  v-if="!!(item.badge && (item.badge.isDot || item.badge.value))">
28
28
  </fu-badge>
29
29
  </view>
30
- <!-- #ifdef APP-NVUE -->
31
- <view ref="fu-tabs__wrapper__nav__line" class="fu-tabs__wrapper__nav__line"
32
- :style="[{
33
- width:`${lineWidth}px`,
34
- height: firstTime? 0: `${lineHeight}px`,
35
- background: lineColor,
36
- backgroundSize: lineBgSize
37
- }]">
38
- <!-- #endif -->
39
- <!-- #ifndef APP-NVUE -->
40
- <view ref="fu-tabs__wrapper__nav__line" class="fu-tabs__wrapper__nav__line"
41
- :style="[{
42
- width: `${lineWidth}px`,
43
- transform: `translate(${lineOffsetLeft}px)`,
44
- transitionDuration: `${firstTime? 0 : duration}ms`,
45
- height: firstTime? 0: `${lineHeight}px`,
46
- background: lineColor,
47
- backgroundSize: lineBgSize,
48
- }]">
49
- <!-- #endif -->
50
- </view>
30
+ <view ref="fu-tabs__wrapper__nav__line" class="fu-tabs__wrapper__nav__line" :style="[lineStyle]"></view>
51
31
  </view>
52
32
  </scroll-view>
53
33
  </view>
@@ -67,7 +47,7 @@
67
47
  // #endif
68
48
  /**
69
49
  * Tabs 标签
70
- * @description t此组件在标签多的时候,可以配置为左右滑动,标签少的时候,可以禁止滑动。 该组件的一个特点是配置为滚动模式时,激活的tab会自动移动到组件的中间位置。
50
+ * @description 此组件在标签多的时候,可以配置为左右滑动,标签少的时候,可以禁止滑动。 该组件的一个特点是配置为滚动模式时,激活的tab会自动移动到组件的中间位置。
71
51
  * @property {Array} list 标签数组,元素为对象,如[{name: '推荐'}]
72
52
  * @property {String,Number} duration 滑块移动一次所需的时间,单位秒(默认 300 )
73
53
  * @property {String,Object} activeStyle 菜单选择中时的样式(默认{ color: '#303133' })
@@ -81,14 +61,15 @@
81
61
  * @property {String} scrollable = [true|false] 菜单是否可滚动,选项很少的时候设置为false整个tabs自动居中显示(默认:true)
82
62
  * @property {String,Number} current 当前选中标签的索引(默认 0 )
83
63
  * @property {String} keyName 从list元素对象中读取的键名(默认 'name' )
84
- * @event {Function(index)} change 标签改变时触发 index: 点击了第几个tab,索引从0开始
85
- * @event {Function(index)} click 点击标签时触发 index: 点击了第几个tab,索引从0开始
64
+ *
65
+ * @event {Function} change 标签改变时触发 index: 点击了第几个tab,索引从0开始
66
+ * @event {Function} click 点击标签时触发 index: 点击了第几个tab,索引从0开始
86
67
  * @example <fu-tabs :list="list" :current="current" @change="change"></fu-tabs>
87
68
  */
88
69
  export default {
89
70
  name: 'FuTabs',
90
- emits: ['click','change'],
91
71
  mixins: [mpMixin, props],
72
+ emits: ['click','change'],
92
73
  data() {
93
74
  return {
94
75
  firstTime: true,
@@ -117,6 +98,21 @@
117
98
  },
118
99
  propsBadge() {
119
100
  return fuBadgeProps
101
+ },
102
+ lineStyle() {
103
+ let style = {
104
+ width: `${this.lineWidth}px`,
105
+ height: this.firstTime? 0: `${this.lineHeight}px`,
106
+ background: this.lineColor,
107
+ backgroundSize: this.lineBgSize,
108
+ };
109
+
110
+ // #ifndef APP-NVUE
111
+ style.transform = `translate(${this.lineOffsetLeft}px)`;
112
+ style.transitionDuration = `${this.firstTime? 0 : this.duration}ms`;
113
+ // #endif
114
+
115
+ return style
120
116
  }
121
117
  },
122
118
  async mounted() {
@@ -133,7 +129,7 @@
133
129
  // 获取下划线的数值px表示法
134
130
  let lineWidth = this.$fu.getPx(this.lineWidth);
135
131
  // 如果传的值未带单位+设置了全局单位,则带上单位计算,这样才没有误差
136
- if (this.$fu.number(this.lineWidth) && 'px') {
132
+ if (this.$fu.checkNumber(this.lineWidth) && 'px') {
137
133
  lineWidth = this.$fu.getPx(`${this.lineWidth}px`);
138
134
  }
139
135
  this.lineOffsetLeft = lineOffsetLeft + (tabItem.rect.width - lineWidth) / 2;
@@ -149,6 +145,7 @@
149
145
  }, 20);
150
146
  }
151
147
  },
148
+
152
149
  // nvue下设置滑块的位置
153
150
  animation(x, duration = 0) {
154
151
  // #ifdef APP-NVUE
@@ -161,8 +158,9 @@
161
158
  })
162
159
  // #endif
163
160
  },
161
+
164
162
  // 点击某一个标签
165
- clickHandler(item, index) {
163
+ handleClick(item, index) {
166
164
  // 因为标签可能为disabled状态,所以click是一定会发出的,但是change事件是需要可用的状态才发出
167
165
  this.$emit('click', {
168
166
  ...item,
@@ -191,11 +189,13 @@
191
189
  })
192
190
  // #endif
193
191
  },
192
+
194
193
  init() {
195
194
  this.$fu.sleep().then(() => {
196
195
  this.resize()
197
196
  })
198
197
  },
198
+
199
199
  setScrollLeft() {
200
200
  // 当前活动tab的布局信息,有tab菜单的width和left(为元素左边界到父元素左边界的距离)等信息
201
201
  const tabRect = this.list[this.innerCurrent];
@@ -211,6 +211,7 @@
211
211
  scrollLeft = Math.min(scrollLeft, this.scrollViewWidth - this.tabsRect.width);
212
212
  this.scrollLeft = Math.max(0, scrollLeft);
213
213
  },
214
+
214
215
  // 获取所有标签的尺寸
215
216
  resize() {
216
217
  // 如果不存在list,则不处理
@@ -231,12 +232,14 @@
231
232
  this.setScrollLeft()
232
233
  })
233
234
  },
235
+
234
236
  // 获取导航菜单的尺寸
235
237
  getTabsRect() {
236
238
  return new Promise(resolve => {
237
239
  this.queryRect('fu-tabs__wrapper__scroll-view').then(size => resolve(size))
238
240
  })
239
241
  },
242
+
240
243
  // 获取所有标签的尺寸
241
244
  getAllItemRect() {
242
245
  return new Promise(resolve => {
@@ -244,6 +247,7 @@
244
247
  Promise.all(promiseAllArr).then(sizes => resolve(sizes))
245
248
  })
246
249
  },
250
+
247
251
  // 获取各个标签的尺寸
248
252
  queryRect(el, item) {
249
253
  // #ifndef APP-NVUE
@@ -289,13 +293,13 @@
289
293
  }
290
294
  </script>
291
295
  <style lang="scss" scoped>
292
- @import '../../libs/css/color.scss';
296
+ @import '../../libs/style/components.scss';
297
+ @import '../../libs/style/color.scss';
293
298
 
294
299
  .fu-tabs {
295
300
 
296
301
  &__wrapper {
297
- display: flex;
298
- flex-direction: row;
302
+ @include flex(row);
299
303
  align-items: center;
300
304
 
301
305
  &__scroll-view-wrapper {
@@ -306,8 +310,7 @@
306
310
  }
307
311
 
308
312
  &__scroll-view {
309
- display: flex;
310
- flex-direction: row;
313
+ @include flex(row);
311
314
  flex: 1;
312
315
  }
313
316
 
@@ -1,50 +1,72 @@
1
1
  export default {
2
2
  props: {
3
- // 滑块的移动过渡时间,单位ms
3
+ /**
4
+ * @description 滑块的移动过渡时间,单位ms
5
+ * @default 300
6
+ */
4
7
  duration: {
5
8
  type: Number,
6
9
  default: 300
7
10
  },
8
- // tabs标签数组
11
+ /**
12
+ * @description tabs标签数组
13
+ */
9
14
  list: {
10
15
  type: Array,
11
16
  default: () => []
12
17
  },
13
- // 滑块颜色
18
+ /**
19
+ * @description 滑块颜色
20
+ */
14
21
  lineColor: {
15
22
  type: String,
16
23
  default: ''
17
24
  },
18
- // 菜单选择中时的样式
25
+ /**
26
+ * @description 菜单选择中时的样式
27
+ */
19
28
  activeStyle: {
20
29
  type: [String,Object],
21
30
  default: () => ({
22
31
  color: '#303133'
23
32
  })
24
33
  },
25
- // 菜单非选中时的样式
34
+ /**
35
+ * @description 菜单非选中时的样式
36
+ */
26
37
  inactiveStyle: {
27
38
  type: [String, Object],
28
39
  default: () => ({
29
40
  color: '#606266'
30
41
  })
31
42
  },
32
- // 滑块长度
43
+ /**
44
+ * @description 滑块长度
45
+ * @default 20
46
+ */
33
47
  lineWidth: {
34
48
  type: [String,Number],
35
49
  default: 20
36
50
  },
37
- // 滑块高度
51
+ /**
52
+ * @description 滑块高度
53
+ * @default 3
54
+ */
38
55
  lineHeight: {
39
56
  type: [String,Number],
40
57
  default: 3
41
58
  },
42
- // 滑块背景显示大小,当滑块背景设置为图片时使用
59
+ /**
60
+ * @description 滑块背景显示大小,当滑块背景设置为图片时使用
61
+ * @default 'cover'
62
+ */
43
63
  lineBgSize: {
44
64
  type: String,
45
65
  default: 'cover'
46
66
  },
47
- // 菜单item的样式
67
+ /**
68
+ * @description 菜单item的样式
69
+ */
48
70
  itemStyle: {
49
71
  type: [String, Object],
50
72
  default: () => ({
@@ -52,22 +74,33 @@ export default {
52
74
  padding: '0 15px'
53
75
  })
54
76
  },
55
- // 菜单是否可滚动
77
+ /**
78
+ * @description 菜单是否可滚动
79
+ * @default true
80
+ */
56
81
  scrollable: {
57
82
  type: Boolean,
58
83
  default: true
59
84
  },
60
- // 当前选中标签的索引
85
+ /**
86
+ * @description 当前选中标签的索引
87
+ */
61
88
  current: {
62
89
  type: [String,Number],
63
90
  default: 0
64
91
  },
65
- // 默认读取的键名
92
+ /**
93
+ * @description 默认读取的键名
94
+ * @default 'name'
95
+ */
66
96
  keyName: {
67
97
  type: String,
68
98
  default: 'name'
69
99
  },
70
- // 各个元素的内边距可在itemStyle设置
100
+ /**
101
+ * @description 各个元素的内边距可在itemStyle设置
102
+ * @default '0 15px'
103
+ */
71
104
  padding: {
72
105
  type: String,
73
106
  default: '0 15px'