/*时间戳,以ms为单位*/
function changeTime (inputTime){
var date = new Date(inputTime);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? ('0' + m) : m;
var d = date.getDate();
d = d < 10 ? ('0' + d) : d;
var h = date.getHours();
h = h < 10 ? ('0' + h) : h;
var minute = date.getMinutes();
var second = date.getSeconds();
minute = minute < 10 ? ('0' + minute) : minute;
second = second < 10 ? ('0' + second) : second;
return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
}
<span>
<input class="idCard" type="text" name="idCard" placeholder="身份证" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"></span>
- JS运算
浮点数运算会有计算bug
精确两位用toFixed(2)
- 数组的深拷贝复杂对象集合
var deepCopy = function(o) {
if (o instanceof Array) {
var n = [];
for (var i = 0; i < o.length; ++i) {
n[i] = deepCopy(o[i]);
}
return n;
} else if (o instanceof Object) {
var n = {}
for (var i in o) {
n[i] = deepCopy(o[i]);
}
return n;
} else {
return o;
}
}
function(){
let info = JSON.stringify(item);
let recode = encodeURIComponent(info);
console.log(recode);
window.location.href="health-evaluation-scheme-pic.html?item="+recode
}
function getQueryString(key){
var reg = new RegExp("(^|&)"+key+"=([^&]*)(&|$)");
var result = window.location.search.substr(1).match(reg);
return result?decodeURIComponent(result[2]):null;
}
function GetQueryString(name){
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
网友评论