- 博客(8)
- 收藏
- 关注
原创 防抖与节流概念
防抖与节流//防抖<body> <input type="text" id="inp"> <script> var oInp = document.getElementById('inp'); function ajax(e) { console.log(e, this.value); } function debounce(handler, delay) {
2021-08-07 16:28:20 96
原创 数组去重方法
// 数组去重Array.prototype.unique = function(){ var temp = {}; var arr = []; var len = this.length; for(var i = 0; i < len; i++){ if(!temp[this[i]]){ temp[this[i]] = 'abc'
2021-08-05 15:56:25 101
原创 js深度克隆
// 深度克隆 // 深度克隆 function deepClone(target,origin){ var target = target || {}, toStr = Obejct.prototype.toString, arrStr = '[object Array]'; for(var prop in origin){ if(origin.
2021-08-05 13:36:21 87
原创 js圣杯模式
// 圣杯模式var inherit = function(){ var F = function(){}; return function(target,origin){ F.prototype = origin.prototype; target.prototype = new F(); target.prototype.constructor = target; target.prototype.uber = origin.prototype;}
2021-08-05 13:28:48 249
原创 move运动函数
//封装一个运动函数// Move function getStyle(ele, attr) { if (window.getComputedStyle) { return window.getComputedStyle(ele, null)[attr]; } else { return ele.currentStyle[attr]; } } function startMove(dom, attrObj, callback) {
2021-08-05 13:18:45 221
原创 bind方法源码
//bind封装源码Function.prototype.newBind = function (target) { target = target || window; var self = this; var args = [].slice.call(arguments, 1); var temp = function () {}; var F = function () { var _arg = [].slice.call(arguments,
2021-08-05 13:16:51 283
原创 封装cookie方法
封装一个cookie方法var myCookie = { // 设置cookie set: function (name, value, date) { // max-age 要求用户传入的是过期的秒数 document.cookie = name + '=' + value + '; max-age=' + date }, // 移除cookie remove: function (name) {
2021-08-05 13:12:32 139
原创 drag方法——>拖拽
drag方法 拖拽 var drag = { init: function (dom) { this.dom = dom; this.bindEvent(); }, bindEvent: function () { this.dom.onmousedown = this.mouseDown.bind(this); }, mouseDown: function (e) { docume
2021-08-05 13:01:33 384
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人