西藏巴青项目

tabPage.js 758B

123456789101112131415161718192021222324252627282930313233343536
  1. import { isTabBarPage, syncTabBarText } from '@/utils/tabBar'
  2. /**
  3. * Tab 子页共用:根节点语言 class、导航标题、底部 tab 文案与 i18n 同步
  4. * 页面需在 data 中提供 navTitleKey,如 'nav.home'
  5. */
  6. export default {
  7. data() {
  8. return {
  9. layoutKey: 0
  10. }
  11. },
  12. computed: {
  13. lang() {
  14. return this.$i18n.locale
  15. },
  16. pageRootClass() {
  17. return this.lang === 'bo' ? 'lang-bo' : 'lang-zh'
  18. }
  19. },
  20. onShow() {
  21. if (isTabBarPage()) {
  22. syncTabBarText((k) => this.$t(k))
  23. }
  24. const key = this.navTitleKey
  25. if (key) {
  26. const p = uni.setNavigationBarTitle({
  27. title: this.$t(key)
  28. })
  29. if (p && typeof p.catch === 'function') {
  30. p.catch(() => {})
  31. }
  32. }
  33. }
  34. }