Feature: 为网页标题添加国际化
This commit is contained in:
13
src/App.vue
13
src/App.vue
@ -83,6 +83,11 @@
|
||||
const selectedIndex = ref(0)
|
||||
const windowWidth = ref(typeof window === 'undefined' ? 1200 : window.innerWidth)
|
||||
|
||||
// 动态设置网页标题
|
||||
const pageTitle = computed(() => {
|
||||
return t('appTitle')
|
||||
})
|
||||
|
||||
// 监听窗口变化
|
||||
const handleResize = () => {
|
||||
if (typeof window === 'undefined') return
|
||||
@ -195,4 +200,12 @@
|
||||
selectedIndex.value = index
|
||||
drawer.value = false // 选择后自动关闭抽屉
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
document.title = pageTitle.value
|
||||
})
|
||||
|
||||
watch(locale, () => {
|
||||
document.title = pageTitle.value
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user