## 偽數組正常化
```
//偽數組
var ss = {0: 'Marvin', 1: 'lili'}
Array.prototype.slice.call(ss)
=> [Marvin , lili]
```
*****
*****
## 數組最大值
```
function getMax(arr){
var arrLen=arr.length;
for(var i=0,ret=arr[0];i<arrLen;i++){
ret=Math.max(ret,arr[i]);
}
return ret;
}
```
*****
*****
## 數組合并
```
var array1 = [1 , 2 , 3, 5];
var array2 = ["xie" , "li" , "qun" , "tsrot"];
Array.prototype.push.apply(array1, array2);
```
*****
*****
## 閉包權限收斂
```
function isFirstLoad(){
var _list=[];
return function(id){
if(_list.indexOf(id)>=0){
return false;
}else{
_list.push(id);
return true;
}
}
}
```
## 輪播
```
/*輪播*/
var AutoPlay = function (id) {this.initialize(id)};
AutoPlay.prototype = {
initialize: function (id)
{
var oThis = this;
this.oBox = $(id);
this.oUl = $$("ul", this.oBox)[0];
this.aImg = $$("img", this.oBox);
this.timer = null;
this.autoTimer = null;
this.iNow = 0;
this.creatBtn();
this.aBtn = $$("li", this.oCount);
this.toggle();
this.autoTimer = setInterval(function ()
{
oThis.next()
}, 3000);
this.oBox.onmouseover = function ()
{
clearInterval(oThis.autoTimer)
};
this.oBox.onmouseout = function ()
{
oThis.autoTimer = setInterval(function ()
{
oThis.next()
}, 3000)
};
for (var i = 0; i < this.aBtn.length; i++)
{
this.aBtn[i].index = i;
this.aBtn[i].onmouseover = function ()
{
oThis.iNow = this.index;
oThis.toggle()
}
}
},
creatBtn: function ()
{
this.oCount = document.createElement("ul");
this.oFrag = document.createDocumentFragment();
this.oCount.className = "count";
for (var i = 0; i < this.aImg.length; i++)
{
var oLi = document.createElement("li");
oLi.innerHTML = i + 1;
this.oFrag.appendChild(oLi)
}
this.oCount.appendChild(this.oFrag);
this.oBox.appendChild(this.oCount)
},
toggle: function ()
{
for (var i = 0; i < this.aBtn.length; i++) this.aBtn[i].className = "";
this.aBtn[this.iNow].className = "current";
this.doMove(-(this.iNow * this.aImg[0].offsetHeight))
},
next: function ()
{
this.iNow++;
this.iNow == this.aBtn.length && (this.iNow = 0);
this.toggle()
},
doMove: function (iTarget)
{
var oThis = this;
clearInterval(oThis.timer);
oThis.timer = setInterval(function ()
{
var iSpeed = (iTarget - oThis.oUl.offsetTop) / 5;
iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
oThis.oUl.offsetTop == iTarget ? clearInterval(oThis.timer) : (oThis.oUl.style.top = oThis.oUl.offsetTop + iSpeed + "px")
}, 30)
}
};
//面向對象版運動框架
var Animate = function (oElement, options, callback) {this.initialize.apply(this, arguments)};
Animate.prototype = {
initialize: function (oElement, options, callback)
{
var oThis = this;
this.options = options;
this.callback = callback;
this.oElement = typeof oElement === "string" ? document.getElementById(oElement) : oElement;
clearInterval(this.timer);
this.timer = setInterval(function ()
{
oThis.doMove()
}, 30)
},
css: function (attr, value)
{
if (arguments.length == 1)
{
return parseFloat(this.oElement.currentStyle ? this.oElement.currentStyle[attr] : getComputedStyle(this.oElement, null)[attr])
}
else if (arguments.length == 2)
{
attr == "opacity" ? (this.oElement.style.filter = "alpha(opacity=" + value + ")", this.oElement.style.opacity = value / 100) : this.oElement.style[attr] = value + "px"
}
},
doMove: function ()
{
var opt = this.options;
var bComplete = true;
for (var p in opt)
{
var iCur = p == "opacity" ? parseInt(this.css(p).toFixed(2) * 100) : this.css(p);
var iSpeed = (opt[p] - iCur) / 5;
iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
opt[p] == iCur || (bComplete = false, this.css(p, iCur + iSpeed))
}
bComplete && (clearInterval(this.timer), this.callback && this.callback.call(this))
}
};
```
- css用法技巧
- 陰影被后面div遮擋
- 繪制一個三角形
- 圖像的灰白處理
- 一切居中
- 禁用鼠標事件
- 模糊文本
- 字體省略號
- 垂直居中
- box投影
- css動畫
- javaScript常見工具封裝
- 地址欄參數獲取
- 日期格式化
- Ajax
- scroll
- 緩動函數
- 事件綁定
- 阻止冒泡和默認行為
- 偽數組正常化
- 日期生成
- 拷貝
- javaScript基本知識
- javaScript基本知識
- javascript常見代碼塊
- vue常見問題
- 獲取參數
- vue常見問題/vue混入
- v-html指令問題集錦
- 正則獲取html中所有的中文字符
- 時間格式化
- 監聽路由的變化
- vue移動端滑動事件
- vue移動端圖片點擊放大
- 打包后背景圖片404的問題
- webpack打包后部分樣式失效
- IE的兼容問題
- post請求后臺無法接受參數
- 驗證碼
- vue開啟Gzip報錯
- v-html修改樣式
- app.css文件過大
- vue中中使用iframe
- babel對es6編譯不徹底 出現ie不兼容的問題
- vue單頁應用優化
- 吸頂問題
- 跨域session無法共享
- 登陸返回上一頁
- axois中使用delete數據傳遞問題
- 監聽數組對象數組中的屬性
- webpack
- webpack基本使用
- webpack打包刪除注釋
- js插件
- 輪播圖
- 面向對象模板
- 左滑右滑
- 存儲
- appcan
- appcan
- js深入研究
- 數組的參數傳遞問題
- 采用jquery的方法載入公共頁面后出現閃爍的問題
- html拼接無法綁定事件
- 吸頂問題
- async配合promise使用
- flutter
- 模擬器加載報錯
- 底部導航實現
- 模擬器出現錯誤
- flutter在idea下的快捷鍵
- flutter學習筆記
- 設計模式
- 觀察者模式
- nest
- nest基本說明
- nest錯誤處理
- vue高級
- 動態注入路由
- nest實戰
- 一項目準備
- window
- 端口進程被占
- mis包
- reactNative
- react-native-router-flux
- esLint
- eslint
- Cesium