移动端问题记录

移动端问题记录

1.ios猎豹浏览器 a标签不能加target=”_blank”
2.微信上屏蔽了分享菜单,跳转页面后,ios的webview不会销毁屏蔽,需要手动显示出来,Android无此问题

1
2
3
4
5
6
7
8
wx.ready(function () {
if (!sign.share){
wx.hideOptionMenu();
return;
}
// ios上跳转页面由于安全机制会使得下一个页面也hideOptionMenu
wx.showOptionMenu();
}

3.ios微信transform: translate(0,-100%) rotateY(0);双动画需要初始化问题,即如果没有初始化rotateY,之后如果要在keyframes里面进行变化是不行的
4.ios safari audio标签设置autoplay失效,解决方案绑定touchstart手动触发
5.去除button在ios上的默认样式

1
2
-webkit-appearance: none;
border-radius: 0

6.判断Android还是ios

1
2
3
4
5
6
7
if (/android/i.test(navigator.userAgent)) {
// android
}

if (/ipad|iphone|mac/i.test(navigator.userAgent)) {
// ios
}

7.打电话

1
<a href="tel:0755-10086">打电话给:0755-10086</a>

8.发短信

1
<a href="sms:10086">发短信给: 10086</a>

WP会失效。。。。。

9.隐藏电话号码中间四位.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
let number = '13500430323';
let number2 = '13333333333';

// 方法1,问题在于使用substr可能会带来第一次匹配不是中间4位
function hideFun(num) {
if(!num) {
return '';
}
return num.replace(num.substr(3, 4), 'xxxx');
}

// 方法2,正则$1和$2来去除两侧表达式
function hideFun2(num) {
if(!num) {
return '';
}
return num.replace(/^(\d{3})\d{4}(\d{4})$/, '$1xxxx$2');
}

// 方法3,在方法1基础上调用2次substr来拼接
function hideFun3(num) {
if(!num) {
return '';
}
return num.substr(0, 3) + 'xxxx' + num.substr(7, 4);
}

console.log(hideFun(number)); // 135xxxx0323
console.log(hideFun(number2)); // 1xxxx333333

console.log(hideFun2(number)); // 135xxxx0323
console.log(hideFun2(number2)); // 1xxxx333333

console.log(hideFun3(number)); // 135xxxx0323
console.log(hideFun3(number2)); // 1xxxx333333