//打開微信小程序後,部分模板綁定數據是通過接口調取的,當遇到數據的時間被json格式化後,需要正常的顯示。可以通過擴展一個方法去處理時間。 1.打開utils裏的utils.js ,也可以按照自己的習慣添加我們需要擴展的函數renderTime,方法如下 function renderTime(date) { var da = new Date(parseInt(date.replace("/Date(", "").replace(")/", "").split("+")[0])); var Year = da.getFullYear(); //ie火狐下都可以 var Month = da.getMonth() + 1; var Day = da.getDate(); var Hours=da.getHours(); var Minutes=da.getMinutes(); var Seconds=da.getSeconds(); var CurrentDate = ""; CurrentDate += Year + "-"; if (Month >= 10) { CurrentDate += Month + "-"; } else { CurrentDate += "0" + Month + "-"; } if (Day >= 10) { CurrentDate += Day; } else { CurrentDate += "0" + Day; } if (Hours <10) { Hours = "0" + Hours; } if (Minutes < 10) { Minutes ="0"+ Minutes; } if (Seconds < 10) { Seconds ="0"+ Seconds; } return CurrentDate + " " + Hours + ":" + Minutes + ":" + Seconds; } //引用的話,只需要在你的頁面下的js裏 var util = require('../../utils/util.js'); 你放置這個函數。 當然,utils裏的 //擴展的方法需要在Module裏去聲明 module.exports = { renderTime:renderTime } 調用方法。便是 util.renderTime(date);即可。