【[调试bug]JS:getFullYear is not a function】报错,getFullYear is not a function
原报错的代码:
this.formatFun = function(time) {
var year = time.getFullYear();
var month = time.getMonth()+1;
var date = time.getDate();
var hour = time.getHours();
var minutes = time.getMinutes();
var seconds = time.getSeconds();
return year+'年'+month +'月' + date +'日' + hour +':' + minutes+':'+ seconds
}
原因:js调用的方法中少了这一句:
var time = new Date(time);