跳到主要内容

106 篇博文 含有标签「前端开发」

查看所有标签

javascript Date类型扩展日期格式化方法 DateFormat

· 阅读需 1 分钟
一介布衣
全栈开发者
Date.prototype.Format = function (fmt) { //author: meizz 
var o = {
“M+”: this.getMonth() + 1, //月份
“d+”: this.getDate(), //日
“h+”: this.getHours(), //小时
“m+”: this.getMinutes(), //分
“s+”: this.getSeconds(), //秒
“q+”: Math.floor((this.getMonth() + 3) / 3), //季度
“S”: this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + “”).substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp(“(“ + k + “)”).test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : ((“00″ + o[k]).substr((“” + o[k]).length)));
return fmt;
}

Grunt watch 跑起来后,还要防止任务越绑越重

· 阅读需 2 分钟
一介布衣
全栈开发者

Grunt watch 刚接进项目时,体验真的很好。改一个文件,自动检查、自动编译、自动刷新,前端开发节奏会立刻顺起来。但 2013 年我在几个页面项目里把它用深之后,也很快遇到另一个问题:watch 一旦开始什么都监听、什么都触发,最后开发环境会变得越来越重。