Segmented Control 分段器

使用指南

在 page.json 中引入组件

  1. "usingComponents": {
  2. "w-segmented-control": "wuss-weapp/w-segmented-control/index",
  3. }

图片演示

SegmentedControl 分段器 - 图1

代码演示

  1. <view
  2. style="margin: 30px 0;"
  3. hover-class="none"
  4. hover-stop-propagation="false"
  5. >
  6. <w-segmented-control styles="font-size: 14px;" options="{{ options1 }}" />
  7. </view>
  8. <view
  9. style="margin: 30px 0;"
  10. hover-class="none"
  11. hover-stop-propagation="false"
  12. >
  13. <w-segmented-control
  14. color="#1c75f3"
  15. defaultIndex="2"
  16. styles="font-size: 14px;"
  17. options="{{ options2 }}"
  18. />
  19. </view>
  20. <view
  21. style="margin: 30px 0;"
  22. hover-class="none"
  23. hover-stop-propagation="false"
  24. >
  25. <w-segmented-control
  26. color="#e42112"
  27. defaultIndex="1"
  28. styles="font-size: 14px;"
  29. options="{{ options3 }}"
  30. />
  31. </view>
  32. <view
  33. style="margin: 30px 0;"
  34. hover-class="none"
  35. hover-stop-propagation="false"
  36. >
  37. <w-segmented-control
  38. disabled
  39. color="green"
  40. styles="font-size: 14px;"
  41. options="{{ options4 }}"
  42. />
  43. </view>
  1. data: {
  2. options1: ['Segment1','Segment2'],
  3. options2: ['Segment1','Segment2','Segment3','Segment4'],
  4. options3: ['Segment1','Segment2','Segment3'],
  5. options4: ['Segment1','Segment2','Segment3'],
  6. },

API

Attribute 属性

属性说明类型默认值
options传入的选项组 ['xxx','xxx','xxx','xxx']string[]
color组件的主色调string#ff9900
disabled禁用boolean-
defaultIndex初始化默认的索引number0
styles自定义样式string-

Event 事件

事件名说明参数
onChange值改变时触发e.detail.value

Slot 插槽

名称说明
slot指定的图片验证码

Class 自定义类名

类名说明
wuss-class根节点样式类
wuss-placeholder-class验证码输入框的placeholder样式