new Date("2017-08-11 12:00:00".replace(/-/g, "/"));
line-height:normal; padding:xxpx 0;
### 3) 防止手机中网页放大和缩小。
- viewport 设置不缩放
```html
Element {
-webkit-tap-highlight-color:rgba(255,255,255,0)
}
background-clip: padding-box;
<meta name="viewport" content="user-scalable=no">
<meta name="viewport" content="initial-scale=1,maximum-scale=1">
FastClick 是 FT Labs 专门为解决移动端浏览器 300 毫秒点击延迟问题所开发的一个轻量级的库。FastClick的实现原理是在检测到touchend事件的时候,会通过DOM自定义事件立即出发模拟一个click事件,并把浏览器在300ms之后的click事件阻止掉。
window.addEventListener( "load", function() {
FastClick.attach( document.body );
}, false );
$("#aa").on("touchend", function (event) {
//很多处理比如隐藏什么的
event.preventDefault();
});
在 iOS Safari (其他浏览器和 Android 均不会)上会对那些看起来像是电话号码的数字处理为电话链接,比如:
7 位数字,形如:1234567
带括号及加号的数字,形如:(+86)123456789
双连接线的数字,形如:00-00-00111
11 位数字,形如:13800138000
关闭识别
html复制代码<meta name="format-detection" content="telephone=no" />
邮箱识别
安卓上会对符合邮箱格式的字符串进行识别,我们可以通过如下的 meta 来管别邮箱的自动识别:
<meta content="email=no" name="format-detection" />
<meta name="screen-orientation" content="portrait"> //Android 禁止屏幕旋转
<meta name="full-screen" content="yes"> //全屏显示
<meta name="browsermode" content="application"> //UC应用模式,使用了application这种应用模式后,页面讲默认全屏,禁止长按菜单,禁止收拾,标准排版,以及强制图片显示。
<meta name="x5-orientation" content="portrait"> //QQ强制竖屏
<meta name="x5-fullscreen" content="true"> //QQ强制全屏
<meta name="x5-page-mode" content="app"> //QQ应用模式
div {
-webkit-appearance: none;
}
input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder {
color: #c7c7c7;
}
input:-moz-placeholder,
textarea:-moz-placeholder {
color: #c7c7c7;
}
input:-ms-input-placeholder,
textarea:-ms-input-placeholder {
color: #c7c7c7;
}
body {
-webkit-text-size-adjust: 100% !important;
text-size-adjust: 100% !important;
-moz-text-size-adjust: 100% !important;
}
css复制代码a,button,input,textarea{
-webkit-tap-highlight-color: rgba(0,0,0,0)
-webkit-user-modify:read-write-plaintext-only;
}
$('html').one('touchstart', function() {
audio.play()
})
document.body.addEventListener(
'touchmove',
function(e) {
if (e._isScroller) return
// 阻止默认事件
e.preventDefault()
},
{
passive: false
}
)
FastClick.prototype.focus = function(targetElement) {
var length
if (
deviceIsIOS &&
targetElement.setSelectionRange &&
targetElement.type.indexOf('date') !== 0 &&
targetElement.type !== 'time' &&
targetElement.type !== 'month'
) {
length = targetElement.value.length
targetElement.setSelectionRange(length, length)
targetElement.focus()
} else {
targetElement.focus()
}
}
通过监听键盘回落时间滚动到原来的位置
window.addEventListener('focusout', function() {
window.scrollTo(0, 0)
})
//input输入框弹起软键盘的解决方案。
var bfscrolltop = document.body.scrollTop
$('input')
.focus(function() {
document.body.scrollTop = document.body.scrollHeight
//console.log(document.body.scrollTop);
})
.blur(function() {
document.body.scrollTop = bfscrolltop
//console.log(document.body.scrollTop);
})
<body>
<div class='warper'>
<div class='main'>div>
<div>
<div class="fix-bottom">div>
body>
.warper {
position: absolute;
width: 100%;
left: 0;
right: 0;
top: 0;
bottom: 0;
overflow-y: scroll;
-webkit-overflow-scrolling: touch; /* 解决ios滑动不流畅问题 */
}
.fix-bottom {
position: fixed;
bottom: 0;
width: 100%;
}
navigator.getBattery().then(function (battery) {
// 获取设备电量剩余百分比
var level = battery.level //最大值为1,对应电量100%
console.log('Level: ' + level * 100 + '%')
// 获取设备充电状态
var charging = battery.charging
console.log('充电状态: ' + charging)
// 获取设备完全充电需要的时间
var chargingTime = battery.chargingTime
console.log('完全充电需要的时间: ' + chargingTime)
// 获取设备完全放电需要的时间
var dischargingTime = battery.dischargingTime
console.log('完全放电需要的时间: ' + dischargingTime)
})
navigator.getBattery().then(function (battery) {
// 添加事件,当设备电量改变时触发
battery.addEventListener('levelchange', function () {
console.log('电量改变: ' + battery.level)
})
// 添加事件,当设备充电状态改变时触发
battery.addEventListener('chargingchange', function () {
console.log('充电状态改变: ' + battery.charging)
})
// 添加事件,当设备完全充电需要时间改变时触发
battery.addEventListener('chargingtimechange', function () {
console.log('完全充电需要时间: ' + battery.chargingTime)
})
// 添加事件,当设备完全放电需要时间改变时触发
battery.addEventListener('dischargingtimechange', function () {
console.log('完全放电需要时间: ' + battery.dischargingTime)
})
})
onShow: function(e) {
console.log('showed2', e);
uni.hideTabBar();
//系统获取 本API返回全局唯一的版本更新管理器对象: updateManager,用于管理小程序更新。
const updateManager = uni.getUpdateManager();
console.log(updateManager, "uploadRes");
updateManager.onCheckForUpdate(function(res) {
console.log(res, "uploadRes");//返回true 或 false 是否更新
// 请求完新版本信息的回调
console.log(res.hasUpdate);
if (res.hasUpdate) {
updateManager.onUpdateReady(function(res) {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate();
}
}
});
});
updateManager.onUpdateFailed(function(res) {
// 新的版本下载失败
uni.showModal({
title: "新版本已更新!",
content: "新版本已上线,请重启小程序完成更新!"
});
});
}
});
},
这是因为在移动端自适应宽度的代码中,没有把input的自动缩放关闭!一般常见于苹果手机的ios系统,而安卓系统似乎是默认关闭。
input框自动放大,虽然说有便于用户的输入和阅读,但也同时给用户带来了视觉的麻烦,所以一般情况下,我们都是选择关闭自动缩放的!
那么该如何关闭input输入框在手机端的这个缩放效果呢?
1,找到你的网页头部head的代码,查看代码并找到,下面的这段:
这段
2,找到之后,将这段代码更改为:
show-menu-by-longpress | 标签 添加后长按扫描二维码