easyUI设置dateBox的默认值为当前时间

function formatterDate(date) {
        var day = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
        var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : "0"
            + (date.getMonth() + 1);
        return date.getFullYear() + '/' + month + '/' + day;
    };

我们需要在页面加载完成之后进行一些操作

$(function(){
 $('#input_dateTransaction').datebox('setValue', formatterDate(new Date()));
})

这样就可以实现了,网上说的直接设置getDate()的方法是不可行的,因为这样出现的结果会是NAN/NAN/NAN

猜你喜欢

转载自blog.csdn.net/weixin_42424269/article/details/85681614