switch.js 591 B

123456789101112131415161718192021222324252627282930
  1. Page({
  2. data: {
  3. theme: 'light'
  4. },
  5. onShareAppMessage() {
  6. return {
  7. title: 'switch',
  8. path: 'packageComponent/pages/form/switch/switch'
  9. }
  10. },
  11. switch1Change(e) {
  12. console.log('switch1 发生 change 事件,携带值为', e.detail.value)
  13. },
  14. switch2Change(e) {
  15. console.log('switch2 发生 change 事件,携带值为', e.detail.value)
  16. },
  17. onLoad() {
  18. this.setData({
  19. theme: wx.getSystemInfoSync().theme || 'light'
  20. })
  21. if (wx.onThemeChange) {
  22. wx.onThemeChange(({theme}) => {
  23. this.setData({theme})
  24. })
  25. }
  26. }
  27. })