美文网首页
react单页面改变title解决方案

react单页面改变title解决方案

作者: 泽赫 | 来源:发表于2017-10-16 11:06 被阅读26次

    //针对微信端特殊处理

    module.exports = function (title) {
        document.title = title;
        var mobile = navigator.userAgent.toLowerCase();
        // 针对微信
        if (/iphone|ipad|ipod/.test(mobile)) {
            var iframe = document.createElement('iframe');
            iframe.style.display = 'none';
            // 替换成站标favicon路径或者任意存在的较小的图片即可,建议不要使用阿里云cdn的地址,会被微信封掉
            iframe.setAttribute('src', 'xxx.png');
            var iframeCallback = function () {
                setTimeout(function () {
                    iframe.removeEventListener('load', iframeCallback);
                    document.body.removeChild(iframe);
                }, 0);
            };
            iframe.addEventListener('load', iframeCallback);
            document.body.appendChild(iframe);
        }
    };
    

    相关文章

      网友评论

          本文标题:react单页面改变title解决方案

          本文链接:https://www.haomeiwen.com/subject/cyzsfxtx.html