为什么不能在vue-router中更改document.title?

时间:2019-03-15 02:35:41

标签: javascript android vue.js vue-router vue-cli

我正在尝试在vue-router中更改document.title,下面是我的代码:

router.beforeEach((to, from, next) => {
    if (to.meta.title) {
        document.title = to.meta.title
    }
    next()
})

这在iOS上可以正常运行,但在android上效果不佳。

我在应用程序中打开了页面,这是浏览器的userAgent

Mozilla/5.0 (Linux; Android 8.0.0; FRD-AL10 Build/HUAWEIFRD-AL10; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/70.0.3538.110 Mobile Safari/537.36 _MAPP_/5.5.2xmxing

在android中,有时页面标题不会更改,但是挂接的钩子中的代码会返回正确的结果。

mounted() {
    alert(document.title)
}

为什么会这样?

0 个答案:

没有答案