
函数写在util.js页面
function formatTime(date) {
var year = date.getFullYear()
var month = date.getMonth() + 1
var day = date.getDate()
var hour = date.getHours()
var minute = date.getMinutes()
var second = date.getSeconds()
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
function formatNumber(n) {
n = n.toString()
return n[1] ? n : '0' + n
}
module.exports = {
formatTime: formatTime,
}
使用函数
图片描述
图片描述
二、使用相同页面的函数
get_productInformation: function () {
。。。。
},
getZones:function(){
this.get_productInformation
},
三、使用app.js内定义的函数
app.js代码
//app.js
App({
onLaunch: function() {
//调用API从本地缓存中获取数据
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
},
get_a_test:function(){
console.log('this is a test')
},
getUserInfo: function(cb) {
var that = this
if (this.globalData.userInfo) {
typeof cb == "function" &&cb(this.globalData.userInfo)
} else {
//调用登录接口
wx.getUserInfo({
withCredentials: false,
success: function(res) {
that.globalData.userInfo = res.userInfo
typeof cb == "function" &&cb(that.globalData.userInfo)
}
})
}
},
globalData: {
userInfo: null,
college_change:false
}
})
在其他页面中使用
图片描述
可以。首先打开你误删除代码的文件夹,打开电脑的设置,把显示隐藏文件夹勾选了,你会看到。git的隐藏文件夹。然后点开。git文件夹。进入logs。进入refs。进入heads。用记事本打开master(这个master是我本地分支的命名)。我们可以发现00000开头的一定是有特殊意义的,然后第二条信息是我不小心重置的记录,我们再观察得到上面ced17开头的字符串比较可疑。在gitextension上面链接这个文件夹然后输入gitreset--hardced17(完整字符串)。然后再看文件夹,就回来了。
微信(faq)是一种更快速的短邮,具有零资费、跨平台沟通等功能,与传统的短信沟通方式相比,更灵活、智能,且节省资费。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)