合伙人运营小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

theme-change.js 603B

1234567891011121314151617181920212223242526
  1. const themeChangeBehavior = Behavior({
  2. data: {
  3. theme: 'light',
  4. },
  5. attached() {
  6. this._initTheme();
  7. },
  8. methods: {
  9. _initTheme() {
  10. const that = this;
  11. wx.getSystemInfo({
  12. success(res) {
  13. that.setData({
  14. theme: res.theme,
  15. });
  16. },
  17. });
  18. wx.onThemeChange((res) => {
  19. that.setData({
  20. theme: res.theme,
  21. });
  22. });
  23. },
  24. },
  25. });
  26. export default themeChangeBehavior;