- 如何在利用wxs将时间戳转换为日期?
已经在写了如下代码,但页面时间显示依然有问题,并且都是同一个时间 var filter = { getDateTime: function (value) { //不能使用 new Date() var time = getDate(value*1000); var year = time.getFullYear(); var month = time.getMonth() + 1; var date = time.getDate(); var hour = time.getHours(); var minute = time.getMinutes(); var second = time.getSeconds(); month = month < 10 ? "0" + month : month; date = date < 10 ? "0" + date : date; hour = hour < 10 ? "0" + hour : hour; minute = minute < 10 ? "0" + minute : minute; second = second < 10 ? "0" + second : second; return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second; }, module.exports = { getDateTime: filter.getDateTime, } //wxml文件 <wxs src="../../util/util.wxs" module ="filter"/> <text>{{filter.getDateTime(post.time)}}</text> //保存时间戳时的方式 var time = Date.parse(new Date()); time = time / 1000; [图片]
2022-05-09 - 为什么这里还没有获取到数据前端就渲染完毕?
goodlist是在数据库Good表里查postlist里的每个帖子是否被当前用户点赞,pid:帖子id,uid:点赞用户的id 然后前端循环postlist,点赞状态用goodlist里的数据来判断显示,这里console一下goodlist里的数据是有的,但前端没有判断成功是为什么? onShow: function (e) { this.getpos(); }, getpos(){ var c= wx.getStorageSync('com'); var id = wx.getStorageSync('info').id; var that = this; var list=[]; db.collection('Post').where({ //获取全部贴文 major:c, }).orderBy('time','desc').get() .then(res=>{ that.setData({ postlist:res.data }) for(let i =0;i<res.data.length;i++) { db.collection('Good') .where({ pid:res.data[i]._id, uid:id, }) .get() .then(res=>{ if(res.data.length==0) //没有当前用户的点赞信息 { list.push(false) } else list.push(true) }) if(i+1==res.data.length) { console.log(list) that.setData({ goodlist:list }) } } }) .catch(err=>{ console.log("无法获取",err) }) } }, <view wx:for="{{postlist}}" wx:for-item="item" style="background-color: white;" > <image wx:if="{{!goodlist[index]}}" src="../../image/good.png" class="icon" style="right: 100rpx;position: absolute;" bindtap="good" data-index="{{index}}"></image> <image wx:elif="{{goodlist[index]}}" src="../../image/good_2.png" class="icon" style="right: 100rpx;position: absolute;" bindtap="ungood" data-index="{{index}}"></image> </view> [图片] 页面都显示good.png [图片]
2022-05-09 - 请问这是什么数据类型?
我以为是数组,但用下标无法获取内容 for(let i=0;i<src.length;i++) { wx.cloud.uploadFile({ cloudPath:'annimages/'+time+i, filePath:src[i], }) .then(res=>{ p.push(res.fileID); }) } var pl = new Array(); pl = p; console.log("pl",pl); console.log("pl0",pl[0]); [图片]
2022-05-02 - 请问如何向云数据库中传入数组数据?
pic是一个string数组,我想上传到云数据库里,在add里直接用冒号赋值无果,又在then里用push命令添加了一遍还是没有 传进去 [图片] [图片] [图片] pic数组的内容 [图片]
2022-05-01 - 怎么让textarea里的文字自动换行?
[图片] [图片] [图片]
2022-04-28 - 怎么让图片不都显示在同一行导致超出屏幕?
如图多个image标签都显示在同一行然后超出去了 [图片] [图片] [图片]
2022-04-27 - 授权时报参数错误是为什么?
[图片][图片]
2022-04-20