提交 af2da948 编写于 作者: Q qiang

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

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