iOS & Android
# 300ms点击延迟的问题
- 安装fastclick库:
npm install fastclick --save
1
- 在main.Js中写入:
import fastClick from 'fastclick';
fastClick.attach(document.body);
1
2
2
# 禁用放大缩小
- 修改viewport
- 在 iOS 10之前,iOS 和 Android 都可以通过一行 meta 标签来禁止页面缩放:
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
1
iOS 10开始,meta 设置在 Safari 内无效
iOS 有一组双指手势操作的事件:gesturestart
、gesturechange
、gestureend
- 完整禁止缩放代码
window.onload = function() {
// 阻止双击放大
var lastTouchEnd = 0;
document.addEventListener('touchstart', function(event) {
if (event.touches.length > 1) {
event.preventDefault();
}
});
document.addEventListener('touchend', function(event) {
var now = (new Date()).getTime();
if (now - lastTouchEnd <= 300) {
event.preventDefault();
}
lastTouchEnd = now;
}, false);
// 阻止双指放大
document.addEventListener('gesturestart', function(event) {
event.preventDefault();
});
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 引用iconfont的图标
首先在 iconfont 的官网创建一个项目,然后选择图标添加到项目中,然后使用Unicode下载,将解压出来的文件放入项目,
需要的文件有:iconfont.eot
, iconfont.svg
, iconfont.ttf
, iconfont.woff
以及 iconfont.css
文件
<span class="iconfont ">对应图标的unitcode编码</span>
1
# input默认调九宫格数字键盘
<input type="number" pattern="\d*">
1
安卓默认可以调出九宫格, 但 iOS 需要加上
pattern="\d*"
上次更新: 2022/04/23, 03:06:55