index.vue 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <uni-shadow-root class="vant-switch-cell-index"><van-cell center :title="title" :label="label" :border="border" :icon="icon" custom-class="van-switch-cell" :use-label-slot="useLabelSlot">
  3. <slot slot="icon" name="icon"></slot>
  4. <slot slot="title" name="title"></slot>
  5. <slot slot="label" name="label"></slot>
  6. <van-switch :size="size" :checked="checked" :loading="loading" :disabled="disabled" :active-color="activeColor" :inactive-color="inactiveColor" :active-value="activeValue" :inactive-value="inactiveValue" custom-class="van-switch-cell__switch" @change="onChange"></van-switch>
  7. </van-cell></uni-shadow-root>
  8. </template>
  9. <script>
  10. import VanCell from '../cell/index.vue'
  11. import VanSwitch from '../switch/index.vue'
  12. global['__wxVueOptions'] = {components:{'van-cell': VanCell,'van-switch': VanSwitch}}
  13. global['__wxRoute'] = 'vant/switch-cell/index'
  14. import { VantComponent } from '../common/component';
  15. VantComponent({
  16. field: true,
  17. props: {
  18. value: null,
  19. icon: String,
  20. title: String,
  21. label: String,
  22. border: Boolean,
  23. checked: Boolean,
  24. loading: Boolean,
  25. disabled: Boolean,
  26. activeColor: String,
  27. inactiveColor: String,
  28. useLabelSlot: Boolean,
  29. size: {
  30. type: String,
  31. value: '24px'
  32. },
  33. activeValue: {
  34. type: null,
  35. value: true
  36. },
  37. inactiveValue: {
  38. type: null,
  39. value: false
  40. }
  41. },
  42. watch: {
  43. checked(value) {
  44. this.set({ value });
  45. }
  46. },
  47. created() {
  48. this.set({ value: this.data.checked });
  49. },
  50. methods: {
  51. onChange(event) {
  52. this.$emit('change', event.detail);
  53. }
  54. }
  55. });
  56. export default global['__wxComponents']['vant/switch-cell/index']
  57. </script>
  58. <style platform="mp-weixin">
  59. @import '../common/index.css';.van-switch-cell{padding-top:9px;padding-bottom:9px}.van-switch-cell__switch{vertical-align:middle}
  60. </style>