index.ts 814 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { getStatusBarHeight } from '../../store/index'
  2. Component({
  3. externalClasses: ['custom-class'],
  4. properties: {
  5. // 状态栏背景颜色
  6. backgroundColor: {
  7. type: String,
  8. value: '#ffffff',
  9. },
  10. dark: {
  11. type: Boolean,
  12. value: false,
  13. },
  14. },
  15. data: {
  16. styles: ''
  17. },
  18. attached() {
  19. const styles = []
  20. styles.push('padding-top:' + getStatusBarHeight() + 'px')
  21. styles.push('background-color:' + this.data.backgroundColor)
  22. this.setData({
  23. styles: styles.join(';')
  24. })
  25. if (this.data.dark) {
  26. wx.setNavigationBarColor({
  27. frontColor: '#000000',
  28. backgroundColor: '#ffffff',
  29. })
  30. }
  31. }
  32. })