总是头疼javascript的代码写起来不可维护,那么看看下面的代码: (function (w, $) { var app = { init: function () { var me = this; me.render(); me.bind(); }, datas: { num: 1 }, render: function () { var me = this; me.test = $('#table td'); }, bind: function () { var me = this; m
1.磁盘图片缓存器DiskImageCache 1.1.这个类很多情况都可能用的到,耦合性很低,所以分开讲. 源代码: /* * Copyright 2017 GcsSloop * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a co
强制保留两位小数的js方法 //写一个公共的强制保留两位小数的js方法 function toDecimal2 (x) { var f = parseFloat(x) if (isNaN(f)) { return false } var f = Math.round(x * 100) / 100 var s = f.toString() var rs = s.indexOf('.') if (rs < 0) { rs = s.length s += '.' } while (s.length <