Checkbox 复选框

使用指南

在 page.json 中引入组件

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

图片演示

Checkbox 复选框 - 图1

代码演示

  1. <w-pane title="Checkbox" desc="复选框" />
  2. <w-pane desc="Default" />
  3. <w-cell-group>
  4. <w-checkbox options="{{ items1 }}" bind:onChange="handleChange" />
  5. </w-cell-group>
  6. <view>{{ items1Str }}</view>
  7. <w-pane desc="Disabled" />
  8. <w-cell-group>
  9. <w-checkbox options="{{ items2 }}" bind:onChange="handleChange" />
  10. </w-cell-group>
  11. <w-pane desc="Directon" />
  12. <w-cell-group>
  13. <w-checkbox
  14. direction="right"
  15. options="{{ items1 }}"
  16. bind:onChange="handleChange"
  17. />
  18. </w-cell-group>
  19. <w-pane desc="IconType" />
  20. <w-cell-group>
  21. <w-checkbox
  22. icon-type="circle"
  23. direction="right"
  24. options="{{ items1 }}"
  25. bind:onChange="handleChange"
  26. />
  27. <w-checkbox
  28. icon-type="box"
  29. direction="right"
  30. options="{{ items1 }}"
  31. bind:onChange="handleChange"
  32. />
  33. <w-checkbox
  34. icon-type="check"
  35. direction="right"
  36. options="{{ items1 }}"
  37. bind:onChange="handleChange"
  38. />
  39. </w-cell-group>
  40. <w-pane desc="ArrayKeys" />
  41. <w-cell-group>
  42. <w-checkbox
  43. direction="right"
  44. options="{{ items3 }}"
  45. bind:onChange="handleChange"
  46. />
  47. </w-cell-group>
  1. const MOCK_DATA = {
  2. productName: 'iphone X max',
  3. total: 1,
  4. num: 642135,
  5. id: 2143324234,
  6. price: 12700.0,
  7. desc: 'iphone is good',
  8. };
  9. data: {
  10. items1Str: '',
  11. items1: [
  12. {
  13. text: '复选框1',
  14. ...MOCK_DATA,
  15. },
  16. {
  17. text: '复选框2',
  18. ...MOCK_DATA,
  19. },
  20. {
  21. text: '复选框3',
  22. ...MOCK_DATA,
  23. },
  24. ],
  25. items2: [
  26. {
  27. text: '复选框1',
  28. ...MOCK_DATA,
  29. },
  30. {
  31. text: '复选框2',
  32. ...MOCK_DATA,
  33. disabled: true,
  34. },
  35. {
  36. text: '复选框3',
  37. ...MOCK_DATA,
  38. },
  39. ],
  40. items3: ['测试1','测试2','测试3','测试4','测试5'],
  41. },
  42. handleChange(e) {
  43. console.log(e.detail.checked)
  44. this.setData({ items1Str: JSON.stringify(e.detail.checked) });
  45. },

API

Attribute 属性

属性说明类型默认值
color颜色string-
disabled禁用booleanfalse
title标题string-
direction方向,可选值有[left/right]string-
options传入的数组对象,参数有 { label,checked,disabled }array[]

Event 事件

事件名说明参数
onChange勾选点击改变值时触发function:(e) => e.detail.value

Class 自定义类名

类名说明
wuss-class根节点样式类