美文网首页
vue项目,图片长按无法转发给好友和识别

vue项目,图片长按无法转发给好友和识别

作者: 菜鸟秦伟康 | 来源:发表于2019-11-22 18:42 被阅读0次

vue框架做的项目有一个问题,就是ios端图片无法长按转发,这其实是微信内部机制的问题。那我们怎么来处理呢?

办法还是有的,在路由进入当前页面前beforeRouteEnter处理一下。具体代码。把他的url的内容换掉。

beforeRouteEnter(to, from, next) {

// 修复iOS版微信h5 History兼容性问题

    if (isIOS() && to.path !== location.pathname) {

location.assign(to.fullPath); // 此处不可使用location.replace

    }else {

next();

    }

},

这个isIos方法是这样实现的。判断是否ios手机.这样就可以啦嘻嘻。

/**

* 查看手机是不是ios

* */

export function isIOS() {

var isIphone = navigator.userAgent.includes('iPhone');

    var isIpad = navigator.userAgent.includes('iPad');

    return isIphone || isIpad;

}

相关文章

网友评论

      本文标题:vue项目,图片长按无法转发给好友和识别

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