处理如下:

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();
  });
}
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐