1、jq上傳進度
var xhrOnProgress = function (fun) {
xhrOnProgress.onprogress = fun;
return function () {
var xhr = $.ajaxSettings.xhr();
if (typeof xhrOnProgress.onprogress !== 'function')
return xhr;
if (xhrOnProgress.onprogress && xhr.upload) {
xhr.upload.onprogress = xhrOnProgress.onprogress;
}
return xhr;
}
};
$.ajax({
type: "POST",
url: "http://180.97.83.70:30990/wxapp/addUserPhotoAlbumCmd/",
data: formData,
processData: false, //必需false才會自動加上準確的Content-Type
contentType: false,
xhr: xhrOnProgress(function (e) {
var percent = 100 * e.loaded / e.total;//盤算百分比
$("#upinfo").html(Math.floor(percent) + '%');
}),
success: function (res) {
},
error: function (e) {
}
});
});
2、json排序
var testList = [
{n: "1"},
{n: "2"},
{n: "3"},
{n: "4"},
{n: "5"}
];
function sortList(a, b) {
return b.n - a.n
}
testList.sort(sortList)
console.log(testList)
3、獵取7天時候日期
var dates=[];
var datestr;
function getDate() {
var myDate = new Date();
myDate.setDate(myDate.getDate()-6); //前7天
for (var i = 0; i < 7; i++) {
datestr=Number(myDate.getMonth()) + 1 + "-" + myDate.getDate();
dates.push(datestr);
myDate.setTime(myDate.getTime() + 1000*60*60*24);
//console.log(datestr);
}
//$scope.proSevDay=dates;//日期
//console.log(dates);
}
4、推斷頁面轉動究竟部
$(document).ready(function () {
$(window).scroll(function () {
if ($(document).scrollTop() >= $(document).height() - $(window).height()) {
console.log("究竟了")
}
});
});
5、雷同key值到場新數組
var b = {};
result.forEach(function (obj) {
var array = b[obj['time']] || [];
array.push(obj);
b[obj['time']] = array;
});
console.log(b);
6、meta
<!-- 啟用360瀏覽器的極速形式(webkit) -->
<meta name="renderer" content="webkit">
<!-- 防止IE運用兼容形式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- 針對手持裝備優化,主如果針對一些老的不辨認viewport的瀏覽器,比方黑莓 -->
<meta name="HandheldFriendly" content="true">
<!-- 微軟的老式瀏覽器 -->
<!-- 微軟的老式瀏覽器 -->
<meta name="MobileOptimized" content="320">
<!-- uc強迫豎屏 -->
<meta name="screen-orientation" content="portrait">
<!-- QQ強迫豎屏 -->
<meta name="x5-orientation" content="portrait">
<!-- windows phone 點擊無高光 -->
<meta name="msapplication-tap-highlight" content="no">