开关 Switch

基本用法

开关 Switch - 图1

  1. <template lang="html">
  2. <main>
  3. <div class="demo-hidden">
  4. <za-panel>
  5. <za-panel-header title="基本"></za-panel-header>
  6. <za-panel-body>
  7. <za-cell>
  8. <za-switch slot='description' v-model='switch1' @change='handleChange'></za-switch>
  9. 普通
  10. </za-cell>
  11. <za-cell>
  12. <za-switch slot='description' v-model='switch2'></za-switch>
  13. 默认开
  14. </za-cell>
  15. <za-cell>
  16. <za-switch slot='description' v-model='switch3' disabled></za-switch>
  17. 禁用的开关(默认关)
  18. </za-cell>
  19. <za-cell>
  20. <za-switch slot='description' v-model='switch4' disabled></za-switch>
  21. 禁用的开关(默认开)
  22. </za-cell>
  23. </za-panel-body>
  24. </za-panel>
  25. <za-panel>
  26. <za-panel-header title="受控开关"></za-panel-header>
  27. <za-panel-body>
  28. <za-cell>
  29. <za-switch slot='description' v-model='switch5' @change='handleChange2'></za-switch>
  30. 主开关
  31. </za-cell>
  32. <za-cell>
  33. <za-switch slot='description' v-model='switch6'></za-switch>
  34. 受控开关
  35. </za-cell>
  36. </za-panel-body>
  37. </za-panel>
  38. </div>
  39. </main>
  40. </template>
  41. <script>
  42. export default {
  43. data() {
  44. return {
  45. switch1: false,
  46. switch2: true,
  47. switch3: false,
  48. switch4: true,
  49. switch5: false,
  50. switch6: false,
  51. }
  52. },
  53. methods: {
  54. handleChange(event){
  55. console.log(event);
  56. },
  57. handleChange2(){
  58. this.switch6 = this.switch5;
  59. }
  60. },
  61. };
  62. </script>

API

Switch Attributes

属性类型默认值可选值/参数说明
prefixClsstringza-switch类名前缀
themestring'primary''default', 'primary', 'info', 'success', 'warning', 'error'主题
v-modelboolfalse绑定值
disabledboolfalse是否禁用

Switch Event

事件名称说明回调参数
change绑定值改变时的事件event 事件对象