1.

在util文件中建data.js

classUtil{staticformatTime(date){letyeardate.getFullYear();letmonthdate.getMonth()+1;letdaydate.getDate();lethourdate.getHours();letminutedate.getMinutes();letseconddate.getSeconds();return[year,month,day].map(this.formatNumber).join('-')+''+[hour,minute,second].map(this.formatNumber).join(':');};staticformatNumber(n){nn.toString();returnn[1]?n:'0'+n;};};module.exportsUtil;2.

在别的js中引用时

varutilrequire('../../utils/data.js');Page({look:function(){vardatetimeformatTime(newDate())}})

TAG标签: 微信小程序获取当前时间现在小程序多少钱做个小程序需要多少钱

http://www.xiaochengxub.com/read-96165.html