theme-change.js 537 B

1234567891011121314151617181920212223
  1. import { appBaseInfo } from '../common/utils';
  2. const themeChangeBehavior = Behavior({
  3. data: {
  4. theme: 'light',
  5. },
  6. attached() {
  7. this._initTheme();
  8. },
  9. methods: {
  10. _initTheme() {
  11. const that = this;
  12. that.setData({
  13. theme: appBaseInfo.theme,
  14. });
  15. wx.onThemeChange((res) => {
  16. that.setData({
  17. theme: res.theme,
  18. });
  19. });
  20. },
  21. },
  22. });
  23. export default themeChangeBehavior;