commit
ed8d1b6e67
17
src/App.vue
17
src/App.vue
@ -1,8 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { tabBar } from '@/pages.json'
|
||||
|
||||
onLaunch(() => {
|
||||
console.log('App Launch')
|
||||
// #ifdef MP-WEIXIN
|
||||
const setTabbarText = () => {
|
||||
const { t } = useI18n()
|
||||
const tabbarTexts = tabBar.list.map((item) => item.text.replace(/(^%|%$)/g, ''))
|
||||
tabbarTexts.forEach((transKey: string, index: number) => {
|
||||
uni.setTabBarItem({
|
||||
index,
|
||||
text: t(transKey),
|
||||
})
|
||||
})
|
||||
}
|
||||
// fix 微信小程序需要手动调用 api 设置一次国际化tabbar text。
|
||||
setTabbarText()
|
||||
uni.onLocaleChange(setTabbarText)
|
||||
// #endif
|
||||
})
|
||||
onShow(() => {
|
||||
console.log('App Show')
|
||||
|
@ -44,6 +44,16 @@
|
||||
<script lang="ts" setup>
|
||||
import i18n, { t } from '@/locale/index'
|
||||
import { testI18n } from '@/utils/i18n'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
onLoad(() => {
|
||||
// #ifdef MP-WEIXIN
|
||||
// fix 微信小程序需要手动调用 api 设置一次国际化标题。
|
||||
uni.setNavigationBarTitle({ title: t('app.name') })
|
||||
// #endif
|
||||
})
|
||||
|
||||
const current = ref(uni.getLocale())
|
||||
const user = { name: '张三', detail: { height: 178, weight: '75kg' } }
|
||||
|
Loading…
x
Reference in New Issue
Block a user