提交 af2da948 编写于 作者: Q qiang

fix: 修复H5端部分情况document.title不自动更新的问题

上级 34856a1b
...@@ -34,6 +34,9 @@ function setNavigationBar (type, args) { ...@@ -34,6 +34,9 @@ function setNavigationBar (type, args) {
title title
} = args } = args
page.navigationBar.titleText = title page.navigationBar.titleText = title
if (__PLATFORM__ === 'h5') {
document.title = title
}
break break
} }
} }
...@@ -53,4 +56,4 @@ export function hideNavigationBarLoading () { ...@@ -53,4 +56,4 @@ export function hideNavigationBarLoading () {
export function setNavigationBarTitle (args) { export function setNavigationBarTitle (args) {
return setNavigationBar('setNavigationBarTitle', args) return setNavigationBar('setNavigationBarTitle', args)
} }
...@@ -39,9 +39,9 @@ function saveTabBarScrollPosition (id) { ...@@ -39,9 +39,9 @@ function saveTabBarScrollPosition (id) {
function switchTab (routes, to, from) { function switchTab (routes, to, from) {
if ( if (
to && to &&
from && from &&
to.meta.isTabBar && to.meta.isTabBar &&
from.meta.isTabBar from.meta.isTabBar
) { // tabbar 跳 tabbar ) { // tabbar 跳 tabbar
saveTabBarScrollPosition(from.params.__id__) saveTabBarScrollPosition(from.params.__id__)
} }
...@@ -196,6 +196,9 @@ function afterEach (to, from) { ...@@ -196,6 +196,9 @@ function afterEach (to, from) {
setTimeout(function () { setTimeout(function () {
callPageHook(toVm, 'onShow') callPageHook(toVm, 'onShow')
}, 0) }, 0)
if (__PLATFORM__ === 'h5') {
document.title = toVm.$parent.$parent.navigationBar.titleText
}
} }
} }
} }
...@@ -208,4 +211,4 @@ export default function initRouterGuard (appVm, routes) { ...@@ -208,4 +211,4 @@ export default function initRouterGuard (appVm, routes) {
appVm.$router.afterEach(function (to, from) { appVm.$router.afterEach(function (to, from) {
afterEach.call(appVm, to, from) afterEach.call(appVm, to, from)
}) })
} }
<template> <template>
<uni-page :data-page="$route.meta.pagePath"> <uni-page :data-page="$route.meta.pagePath">
<page-head <page-head
v-if="showNavigationBar" v-if="showNavigationBar"
v-bind="navigationBar" /> v-bind="navigationBar" />
<page-refresh <page-refresh
v-if="enablePullDownRefresh" v-if="enablePullDownRefresh"
ref="refresh" ref="refresh"
:color="refreshOptions.color" :color="refreshOptions.color"
:offset="refreshOptions.offset" /> :offset="refreshOptions.offset" />
<page-body <page-body
v-if="enablePullDownRefresh" v-if="enablePullDownRefresh"
@touchstart.native="_touchstart" @touchstart.native="_touchstart"
@touchmove.native="_touchmove" @touchmove.native="_touchmove"
@touchend.native="_touchend" @touchend.native="_touchend"
@touchcancel.native="_touchend"> @touchcancel.native="_touchend">
<slot name="page" /> <slot name="page" />
</page-body> </page-body>
...@@ -173,6 +173,11 @@ export default { ...@@ -173,6 +173,11 @@ export default {
navigationBar, navigationBar,
refreshOptions refreshOptions
} }
},
created () {
if (__PLATFORM__ === 'h5') {
document.title = this.navigationBar.titleText
}
} }
} }
</script> </script>
...@@ -382,15 +382,8 @@ export default { ...@@ -382,15 +382,8 @@ export default {
} }
return btns return btns
} }
},
watch: {
titleText (newVal, oldVal) {
document.title = newVal
}
}, },
mounted () { mounted () {
document.title = this.titleText
if (this.searchInput) { if (this.searchInput) {
const input = this.$refs.input const input = this.$refs.input
input.$watch('composing', val => { input.$watch('composing', val => {
......
...@@ -31,6 +31,11 @@ export default { ...@@ -31,6 +31,11 @@ export default {
default: false default: false
} }
}, },
created () {
if (__PLATFORM__ === 'h5') {
document.title = this.$slots.default[0].text
}
},
methods: { methods: {
_back () { _back () {
this.$emit('back') this.$emit('back')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册