app内部嵌套的h5,document.title设置title在ios中无效
处理如下:const agent = navigator.userAgent;const isiOS = !!agent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);const isAndroid = agent.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端// iOSif
·
处理如下:
const agent = navigator.userAgent;
const isiOS = !!agent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
const isAndroid = agent.indexOf('Android') > -1 || agent.indexOf('Adr') > -1; //android终端
// iOS
if (isiOS) {
router.beforeEach((to, from, next) => {
let title = "测试头部";
if (to.meta.title) {
title = to.meta.title;
}
let _body = document.getElementsByTagName('body')[0];
document.title = title
let _iframe = document.createElement('iframe')
_iframe.style.display = 'none'
_body .appendChild(_iframe)
setTimeout(() => {
document.body.removeChild(_iframe)
}, 300)
next();
});
} else if (isAndroid) {
router.beforeEach((to, from, next) => {
let title = "测试头部";
if (to.meta.title) {
title = to.meta.title;
}
document.title = title;
next();
});
}
更多推荐
已为社区贡献4条内容
所有评论(0)