
javascript
小土豆子额
记录自己工作的知识
展开
-
javaScript中格式化日期毫秒数
function formatDate(date) { var d = new Date(date), month = ” + (d.getMonth() + 1), day = ” + d.getDate(), year = d.getFullYear();if (month.length < 2) month = ‘0’ + month; if (day原创 2017-08-14 17:09:53 · 704 阅读 · 0 评论 -
图片加载完成后获取图片实际宽高
//图片加载完成后获取图片实际宽高 var _test = document.getElementById(“test”); test.onload = function(){ imgSize.call(_test); } function imgSize(){ var imgObj = new Image(); imgObj.src = this.src; aler原创 2017-09-22 13:46:26 · 1190 阅读 · 0 评论 -
ES5中实现ES6的Promise对象
提供代码直接使用 function MyPromise(fn) { this.value; this.status = 'pending'; this.resolveFunc = function() {}; this.rejectFunc = function() {}; fn(this.resolve.bind(this), this.reject.bind(this...原创 2018-05-08 20:18:49 · 2682 阅读 · 0 评论