vue2.0动态改变index中title

来源:互联网 发布:什么手机支持双频网络 编辑:程序博客网 时间:2024/06/05 01:19

第一种

let setDocumentTitle = function (title) {    document.title = title;    let ua = navigator.userAgent;    if (/\bMicroMessenger\/([\d\.]+)/.test(ua) && /ip(hone|od|ad)/i.test(ua)) {        var i = document.createElement('iframe');        i.src = '/favicon.ico';        i.style.display = 'none';        i.onload = function () {            setTimeout(function () {                i.remove();            }, 9);        };        document.body.appendChild(i);    }};

路由跳转前

// 路由跳转前进行title设置router.beforeEach((to, from, next) => {  setDocumentTitle(to.meta.pageTitle)  next()})

第二种

https://github.com/deboyblog/vue-wechat-title

原创粉丝点击