- flex-direction:row无效,是怎么回事?
在wxml中,如果把ms-text的view改成text,flex-direction:row就起作用,但是三角靠右移动不了,就像图2一样,这是什么问题?怎么解决 [图片] [图片] wxml代码: <view class="weui-cell"> <view class="weui-cell_hd">工作性质</view> <picker class="weui-cell_bd" name="work" range='{{worknature}}' value="{{worknature[list1]}}" bindchange="onWorkEvent"> <view class='ms-text'>{{worknature[list1]?worknature[list1]:"请选择"}}</view> <icon class="icon"></icon> </picker> </view> wxss代码: .weui-cell{ display:flex; flex-direction:row; align-items:center; margin-top:25rpx; } .weui-cell_hd{ display:flex; flex-basis:160rpx; font-size:32rpx; } .weui-cell .weui-cell_bd{ display:flex; flex:1; font-size:30rpx; justify-content:center; flex-direction:row; border-bottom:1px solid #cfcece; } .icon { display:flex; display:inline-block; border: 10rpx solid transparent;/*三角形边框*/ border-top: 10rpx solid #666;/*上边框*/ margin-left: 10rpx;/*左边距*/ margin-top: 10rpx;/*右边距*/ margin-right:20rpx; }
2022-08-23 - 当打开发布页面后,地理位置自动弹出,怎么解决?
当打开发布页面时,如第一张图,就自动弹出了地理位置地图,console.log()时,提示有过点击事件。在input组件中用focus="{{false}},关闭了键盘自动弹出,不然一个页面多个input,键盘就会闪,直到最后一个input组件闪现完成。 [图片][图片][图片] wxml代码: <view class="container"> <form bindsubmit="onSubmitEvent"> <selecttwo></selecttwo> <view class="weui-cell"> <view class="weui-cell__hd">工作性质</view> <selectnature name="work" class="weui-cell__bd" prop-array='{{selectArray}}' /> </view> <view class="weui-cell"> <view class="weui-cell__hd">学历要求</view> <selectnature name="education" class="weui-cell__bd" prop-array='{{xueli}}' /> </view> <view class="introduce-group"> <view class="introduce">职位描述</view> <textarea name="content" class="textarea" placeholder="请输入您的招聘要求"></textarea> </view> <view class="location-group"> <view class="location-title">工作地址</view> <view class="location-title-group" bindtap="onLocationTap"> <view class="location-name">{{location?location.address:"请填写您的工作地址"}}</view> <image class="arrow" src="../../../images/arrow.png"></image> </view> </view> <view class="input-group"> <import src="../../input/input.wxml" /> <view class="medata"> <block wx:for="{{cccs}}" wx:key="ccc"> <view data-index="{{index}}"> <template is="medata" data="{{...item}}"></template> </view> </block> </view> </view> <button formType="submit">提交</button> </form> </view> js代码: /** * 打开位置页面 */ openLocationPage(){ const that=this; wx.chooseLocation({ success:res=>{ if(res.address){ delete res["errMsg"]; that.setData({ location:res }) } } }) }, /** * 获取位置信息的事件 */ onLocationTap:function(event){ const that = this; wx.getSetting({ success:res=>{ const isLocation = res.authSetting['scope.userrLocation']; if(isLocation){ that.openLocationPage(); }else{ wx.authorize({ scope:"scope.userLocation", success:res=>{ that.openLocationPage(); } }) } } }) }, input代码 <template name="medata"> <view class="me-list"> <text>{{id}}</text> <input focus="{{false}}" name="name" placeholder="{{value}}"></input> </view> </template>
2022-08-17 - 获取云函数中的真实时间,wxs中的tiem不是日期类型,在JS中如何转换?
在学习如何获取云函数中真实数据中,其他所有的内容都能够显示出来,唯独时间显示不出来,在百度上查了很多,如果wxs中time不是日期类型,在JS中该如何转换?附上图片和代码如下 [图片][图片] 云函数代码: if(errcode == 0){ return await db.collection("weibo").add({ data:{ content:content, location:location, author:author, images:images, video:video, createTime:db.serverDate(),//插入到数据库的时间 device:device } }) }else{ return await {"errcode":1,"errmsg":"您的信息有风险,请修改再发布!"} } [图片] JS代码: db.collection("weibo").get().then(res=>{ // console.log(res); var date = res.data[0].createTime; // console.log(date); var time = new Date(date).getTime(); console.log(time); this.setData({ time:time }) }) WXS代码: var timeFormat = function(time){ console.log(time); var date = getDate(time); console.log(date); var date_seconds = date.getTime() / 1000 ; var now = getDate(); var now_seconds = now.getTime() / 1000; var timestamp = now_seconds - date_seconds; var timeStr = ""; if(timestamp < 60){ timeStr = "刚刚"; }else if(timestamp >= 60 && timestamp < 60 * 60){ var minutes = parseInt(timestamp / 60); timeStr = minutes + "分钟前"; }else if(timestamp >= 60 * 60 && timestamp < 60 * 60 * 24){ var hours = parseInt(timestamp / 60 / 60); timeStr = hours + "小时前"; }else if(timestamp >= 60 * 60 * 24 && timestamp < 60 * 60 * 24 * 30){ var days = parseInt(timestamp / 60 / 60 / 24); timeStr = days + "天前"; }else{ var year = date.getFullYear(); var month = date.getMonth(); var day = date.getDate(); var hour = date.getHours(); var minute = date.getMinutes(); timeStr = year + "/" + month + "/" + day + " " + hour + ":" + minute; } return timeStr; } module.exports={ timeFormat:timeFormat, }
2022-08-08 - 求助,百度了N次,说db.serverDate()创建的时间。无法在WXML中解析?
wxs时间格式化页面时间是正常的,格式化服务器的时间就显示NaN,百度上查很多,有的说,db.serverDate()创建的时间,在wxml中无法解析。怎么解决? [图片][图片][图片][图片] wxs代码: var timeFormat = function(time){ console.log(time); var date = getDate(time); console.log(date); var date_seconds = date.getTime() / 1000; var now = getDate(); var now_seconds = now.getTime() / 1000; var timestamp = now_seconds - date_seconds; var timeStr = ""; if(timestamp < 60){ timeStr = "刚刚"; }else if(timestamp >= 60 && timestamp < 60 * 60){ var minutes = parseInt(timestamp / 60); timeStr = minutes + "分钟前"; }else if(timestamp >= 60 * 60 && timestamp < 60 * 60 * 24){ var hours = parseInt(timestamp / 60 / 60); timeStr = hours + "小时前"; }else if(timestamp >= 60 * 60 * 24 && timestamp < 60 * 60 * 24 * 30){ var days = parseInt(timestamp / 60 / 60 / 24); timeStr = days + "天前"; }else{ var year = date.getFullYear(); var month = date.getMonth(); var day = date.getDate(); var hour = date.getHours(); var minute = date.getMinutes(); timeStr = year + "/" + month + "/" + day + " " + hour + ":" + minute; } return timeStr; } module.exports={ timeFormat:timeFormat, }
2022-08-05 - 如何获取到数据库的真实时间?
在云函数中使用。db.serverDate()直接获取数据库时间,然后模拟器显示NaN,上传两张图片,和代码片段,请高手帮看看,问题出在哪里。。 数据库集合名称:weibo,集合文件中的时间名称为:cretae_time. 打印wxs代码中console.log(time),提示[WXS Runtime info] undefined ,打印wxs中代码console.log(date);提示[WXS Runtime info] Invalid Date [图片][图片] 代码片段链接:https://developers.weixin.qq.com/s/K3OWYemS7IB2
2022-08-03 - 获取真实是数据,模拟器上时间显示NaN,这是什么问题呢?
https://developers.weixin.qq.com/s/c2B9eemp7OB5 以上是简化后的代码片段,求各位大师帮忙解决下,这是什么问题。谢谢了
2022-08-03 - 获取真实的数据,时间显示NaN/NaN/NaN NaN:NaN,求大师帮忙 ?
[图片] console.log(time)显示信息如下 [图片] wxs代码: var timeFormat = function(time){ // console.log(time); var date = getDate(time); console.log(date); var date_seconds = date.getTime() / 1000; var now = getDate(); var now_seconds = now.getTime() / 1000; var timestamp = now_seconds - date_seconds; var timeStr = ""; if(timestamp < 60){ timeStr = "刚刚"; }else if(timestamp >= 60 && timestamp < 60 * 60){ var minutes = parseInt(timestamp / 60); timeStr = minutes + "分钟前"; }else if(timestamp >= 60 * 60 && timestamp < 60 * 60 * 24){ var hours = parseInt(timestamp / 60 / 60); timeStr = hours + "小时前"; }else if(timestamp >= 60 * 60 * 24 && timestamp < 60 * 60 * 24 * 30){ var days = parseInt(timestamp / 60 / 60 / 24); timeStr = days + "天前"; }else{ var year = date.getFullYear(); var month = date.getMonth(); var day = date.getDate(); var hour = date.getHours(); var minute = date.getMinutes(); timeStr = year + "/" + month + "/" + day + " " + hour + ":" + minute; } return timeStr; } module.exports={ timeFormat:timeFormat, } wxml代码 <!--index.wxml--> <wxs src="../../utils/util.wxs" module="util"/> <view class="container"> <view class="weibo-group" wx:for="{{weibos}}" wx:key="weibos" wx:for-item="weibo"> <view class="user-group"> <image class="avatar" src="{{weibo.author.avatarUrl}}"></image> <view class="right-info"> <view class="username">{{weibo.author.nickName}}</view> <view class="detail-info"> <view class="time">{{util.timeFormat(weibo.cretae_time)}}</view> <view class="from">来自{{weibo.device}}</view> </view> </view> </view> 云函数代码: return await db.collection("weibo").add({ data:{ content:content, location:location, author:author, images:images, video:video, cretae_time:db.serverDate(), device:device } })
2022-08-01 - 把数据库的内容变成真实的数据,数据库有内容,但界面不显示数据内容?
[图片] [图片] 上面这个图显示不出内容出来,打印数据库有数据存在,另外就时间怎么显示是NaN?求各位大神帮忙解决下。代码如下: <!--index.wxml--> <wxs src="../../utils/util.wxs" module="util"/> <view class="container"> <view class="weibo-group" wx:for="{{weibos}}" wx:key="weibos" wx:for-item="{{weibo}}"> <view class="user-group"> <image class="avatar" src="{{weibo.author.avatarUrl}}"></image> <view class="right-info"> <view class="username">{{weibo.author.nickName}}</view> <view class="detail-info"> <view class="time">{{util.timeFormat(weibo.cretae_time)}}</view> <view class="from">来自{{weibo.device}}</view> </view> </view> </view> <view class="weibo-content-group"> <view class="content">{{weibo.content}}</view> <block wx:if="{{weibo.images.length > 0}}"> <!--1张图片的情况--> <view wx:if="{{weibo.images.length === 1}}" class="image-list-group"> <image src="cloud://cloud1-9gsfk1on13e42e66.636c-cloud1-9gsfk1on13e42e66-1305874669/images/yingshiji.png" mode="aspectFill" style="width:100%;max-height:400rpx;" /> </view> <!--2张和4张图片的情况--> <view wx:elif="{{weibo.images.length === 2 || weibo.images.length === 4}}" class="image-list-group"> <image wx:for="{{weibo.images}}" wx:key="key" wx:for-item="image" src="{{image}}" mode="aspectFill" style="width:{{twoImageSize}}px;height:{{twoImageSize}}px;" /> </view> <!--3张图片的情况--> <view wx:else class="image-list-group"> <image wx:for="{{weibo.images}}" wx:key="key" wx:for-item="image" src="{{image}}" mode="aspectFill" style="width:{{threeImageSize}}px;height:{{threeImageSize}}px;" /> </view> </block> <!--视频的情况--> <block wx:if="{{weibo.video}}"> <view class="image-list-group"> <video src="{{weibo.video}}"></video> </view> </block> </view> <view class="weibo-handle"> <view class="comment-group"> <image src="../../images/comment.png" />评论 </view> <view class="praise-group"> <image src="../../images/praise.png" />赞 </view> </view> </view> <!--2张和4张图片的情况--> <!--<view class="weibo-group"> <view class="user-group"> <image class="avatar" src="cloud://cloud1-9gsfk1on13e42e66.636c-cloud1-9gsfk1on13e42e66-1305874669/images/1.jpg"></image> <view class="right-info"> <view class="username">forry1</view> <view class="detail-info"> <view class="time">2019/1/1 11:11:11</view> <view class="from">来自iphone XR</view> </view> </view> </view> <view class="weibo-content-group"> <view class="content">大家快来学习小程序开发</view> <view class="image-list-group"> <image src="cloud://cloud1-9gsfk1on13e42e66.636c-cloud1-9gsfk1on13e42e66-1305874669/images/yingshiji.png" mode="aspectFill" style="width:{{twoImageSize}}px;height:{{twoImageSize}}px;" /> <image src="cloud://cloud1-9gsfk1on13e42e66.636c-cloud1-9gsfk1on13e42e66-1305874669/images/yingshiji.png" mode="aspectFill" style="width:{{twoImageSize}}px;height:{{twoImageSize}}px;" /> <image src="cloud://cloud1-9gsfk1on13e42e66.636c-cloud1-9gsfk1on13e42e66-1305874669/images/yingshiji.png" mode="aspectFill" style="width:{{twoImageSize}}px;height:{{twoImageSize}}px;" /> <image src="cloud://cloud1-9gsfk1on13e42e66.636c-cloud1-9gsfk1on13e42e66-1305874669/images/yingshiji.png" mode="aspectFill" style="width:{{twoImageSize}}px;height:{{twoImageSize}}px;" /> </view> </view> <view class="weibo-handle"> <view class="comment-group"> <image src="../../images/comment.png" />评论 </view> <view class="praise-group"> <image src="../../images/praise.png" />赞 </view> </view> </view>--> <!--3张图片的情况--> <!--<view class="weibo-group"> <view class="user-group"> <image class="avatar" src="cloud://cloud1-9gsfk1on13e42e66.636c-cloud1-9gsfk1on13e42e66-1305874669/images/1.jpg"></image> <view class="right-info"> <view class="username">forry1</view> <view class="detail-info"> <view class="time">2019/1/1 11:11:11</view> <view class="from">来自iphone XR</view> </view> </view> </view> <view class="weibo-content-group"> <view class="content">大家快来学习小程序开发</view> <view class="image-list-group"> <image wx:for="{{images}}" wx:key="key" src="cloud://cloud1-9gsfk1on13e42e66.636c-cloud1-9gsfk1on13e42e66-1305874669/images/yingshiji.png" mode="aspectFill" style="width:{{threeImageSize}}px;height:{{threeImageSize}}px;" /> <view wx:if="{{images.length%3 == 2}}" style="width:{{threeImageSize}}px;height:{{threeImageSize}}px;"></view> </view> </view> <view class="weibo-handle"> <view class="comment-group"> <image src="../../images/comment.png" />评论 </view> <view class="praise-group"> <image src="../../images/praise.png" />赞 </view> </view> </view>--> <!--视频的情况--> <!-- <view class="weibo-group"> <view class="user-group"> <image class="avatar" src="cloud://cloud1-9gsfk1on13e42e66.636c-cloud1-9gsfk1on13e42e66-1305874669/images/1.jpg"></image> <view class="right-info"> <view class="username">forry1</view> <view class="detail-info"> <view class="time">2019/1/1 11:11:11</view> <view class="from">来自iphone XR</view> </view> </view> </view> <view class="weibo-content-group"> <view class="content">大家快来学习小程序开发</view> <view class="image-list-group"> <video src="cloud://cloud1-9gsfk1on13e42e66.636c-cloud1-9gsfk1on13e42e66-1305874669/video/汽车视频.mp4"></video> </view> </view> <view class="weibo-handle"> <view class="comment-group"> <image src="../../images/comment.png" />评论 </view> <view class="praise-group"> <image src="../../images/praise.png" />赞 </view> </view> </view>--> </view> <view class="write-weibo-btn" bind:tap="onWriteWeiboTap"> <view>+</view> </view> index.js代码如下: //index.js const app=getApp() const db = wx.cloud.database() Page({ /** * 页面的初始数据 */ data: { images:[1,2,3,4,5,6,7,8,9] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.initImageSize() this.loadWeibos() // this.onWriteWeiboTap() }, loadWeibos:function(){ const that = this; db.collection("weibo").limit(10).get().then(res=>{ // console.log(res); const weibos = res.data; console.log(weibos); that.setData({ weibos:weibos }) }) }, 时间代码如下: // var weekdays = [ // '星期一', // '星期二', // '星期三', // '星期四', // '星期五', // '星期六', // '星期天' // ] // a=10; // console.log(a); var timeFormat = function(time){ var date = getDate(time); var date_seconds = date.getTime() / 1000; var now = getDate(); var now_seconds = now.getTime() / 1000; var timestamp = now_seconds - date_seconds; var timeStr = ""; if(timestamp < 60){ timeStr = "刚刚"; }else if(timestamp >= 60 && timestamp < 60 * 60){ var minutes = parseInt(timestamp / 60); timeStr = minutes + "分钟前"; }else if(timestamp >= 60 * 60 && timestamp < 60 * 60 * 24){ var hours = parseInt(timestamp / 60 / 60); timeStr = hours + "小时前"; }else if(timestamp >= 60 * 60 * 24 && timestamp < 60 * 60 * 24 * 30){ var days = parseInt(timestamp / 60 / 60 / 24); timeStr = days + "天前"; }else{ var year = date.getFullYear(); var month = date.getMonth(); var day = date.getDate(); var hour = date.getHours(); var minute = date.getMinutes(); timeStr = year + "/" + month + "/" + day + " " + hour + ":" + minute; } return timeStr; } module.exports={ timeFormat:timeFormat, // weekdays:weekdays }
2022-07-28 - 云存储路径怎么是undefind?
[图片] [图片] 这路径日期后面显示undefined,求解,这是什么问题? 代码如下: //上传图片到云服务器 const fileIDList=[]; if(that.data.tempImages.length > 0){ const today = new Date(); const year = today.getFullYear(); const month = today.getMonth() +1; const day = today.getDate(); that.data.tempImages.forEach((value,index) => { const cloudPath = "weibos/"+year+"/"+month+"/"+day+"/"+getUUID()+"/"+"."+getExt(value); wx.cloud.uploadFile({ filePath:value, cloudPath:cloudPath, success:res=>{ console.log(res); // fileIDList.push(res.fileID); // if(fileIDList.lenght == that.data.tempImages.lenght){ // //接下来就是发布微博了 // wx.hideLoading({}); // wx.showToast({ // title:"图片都上传完成" // }) // } } }) }) } },
2022-07-26 - 每次更改pages下的文件index中content中内容,就要重新部署云函数,否则就报错?
每次更改pages下的文件index中content中内容,就要重新部署云函数,否则就报错? [图片] // 云函数入口函数 exports.main = async (event, context) => { const content = event.content; const tokenResponse = await got(tokenUrl); const access_token = JSON.parse(tokenResponse.body).access_token; checkUrl = checkurl+access-token; const checkResponse = await got.post(checkUrl,{ body:JSON.stringify({ content:content }) }) return checkResponse.body } // 文字内容安全监测 wx.cloud.callFunction({ name:"msgCheck", data:{ content:"特3456书yuuo莞6543李zxcz蒜7782法fgnv级" }, success:res =>{ console.log(res); }, fail:err => { console.error(err); } })
2022-07-21