第一种

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

Logo

前往低代码交流专区

更多推荐