checkbox


复选框

示例

  1. <template>
  2. <view>
  3. <text class="title">Checkbox</text>
  4. <view class="box">
  5. <checkbox
  6. checked="{{checkboxValue1}}"
  7. disabled="{{false}}"
  8. label="Checkbox1"
  9. c-bind:change="valueChange1"
  10. >
  11. </checkbox>
  12. </view>
  13. <view class="title"><text>value: {{ checkboxValue1 ? 'true' : 'false' }}</text></view>
  14. <view class="box">
  15. <checkbox
  16. checked="{{checkboxValue2}}"
  17. label="Checkbox2"
  18. position="right"
  19. c-bind:change="valueChange2"
  20. >
  21. </checkbox>
  22. </view>
  23. <view class="title"><text>value: {{ checkboxValue2 ? 'true' : 'false' }}</text></view>
  24. <view class="box">
  25. <checkbox
  26. checked="{{checkboxValue3}}"
  27. label="Checkbox3"
  28. position="right"
  29. disabled="{{true}}"
  30. >
  31. </checkbox>
  32. </view>
  33. <view class="title"><text>value: {{ checkboxValue3 ? 'true' : 'false' }}</text></view>
  34. </view>
  35. </template>
  36. <script>
  37. class Checkbox {
  38. data = {
  39. checkboxValue1: true,
  40. checkboxValue2: true,
  41. checkboxValue3: true
  42. }
  43. methods = {
  44. valueChange1 (e) {
  45. this.checkboxValue1 = e.detail.value
  46. },
  47. valueChange2 (e) {
  48. this.checkboxValue2 = e.detail.value
  49. }
  50. }
  51. }
  52. export default new Checkbox();
  53. </script>
  54. <style scoped>
  55. .container {
  56. position: absolute;
  57. top: 88cpx;
  58. left: 0;
  59. right: 0;
  60. bottom: 0;
  61. }
  62. .title {
  63. font-size: 38cpx;
  64. font-weight: 400;
  65. margin: 20cpx 0;
  66. padding: 8cpx 30cpx;
  67. background: #eee
  68. }
  69. .checkbox-value {
  70. font-size: 32cpx;
  71. }
  72. .box {
  73. margin: 10cpx 50cpx;
  74. }
  75. </style>
  76. <script cml-type="json">
  77. {
  78. "base": {}
  79. }
  80. </script>