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;
}
网友评论