onLoad(options) { console.log(options); let id=options.id; wx.getStorage({ key:'user', success:(res)=>{ console.log(res); let uid=res.data.id; wx.request({ url: 'http://www.day1128.com/detail', data:{ id:id,uid:uid }, success:(ress)=>{ console.log(ress); let data=ress.data.data; this.setData({data}); } }) } }) }, <view> <view>{{data.title}}</view> <view>{{data.content}}</view> <view><image src="{{data.img}}"></image></view> </view>
为何wx.showToast 频繁触发,停留时间不足默认的1500毫秒?当我频繁的通过一个事件触发 wx.showToast 时,后续几次 showToast的显示时间不足1500毫秒 showToast(){ wx.hideToast() // 即使hideToast也不管用 wx.showToast({ title: '这是一段提示', duration: 1500, icon: 'none' }) }
2022-11-27favor(e){ let key=e.target.dataset.index; let that=this; let id=e.target.dataset.id; //获取文章id wx.getStorage({ key:'user', success:(res)=>{ let uid=res.data.id;//获取点赞文章的用户id wx.request({ url: 'http://www.day1128.com/favor', data:{id:id,uid:uid}, success:(ress)=>{ let is_like=ress.data.is_like; let box=that.data.box; if(is_like==1){ box[key]['is_like']=1 }else{ box[key]['is_like']=0 } that.setData({box}); } }) }})}, onLoad(options) { this.getData(1); wx.getStorage({ key:'user', success:(result)=>{ let user=result.data; let info=this.data.info; info=info.concat(user); this.setData({info}); } }) },
wx.showToast为什么会调用异常?[图片]
2022-11-27<wxs src="../../utils/splice.wxs" module="mytool"></wxs> <view class="user" wx:for="{{info}}" wx:key="info"> <view><image src="{{item.avatar}}" class="img"></image></view> <view >{{item.nickname}}</view> </view> <view class="box" wx:for="{{box}}" wx:key="box"> <view class="box1"> <view class="title" bind:tap="goto" data-id="{{item.id}}">{{item.title}}</view> <view>{{mytool.mysub(item.content,0,20)}}</view> <view wx:if="{{item.is_like==1}}"> <view class="iconfont icon-dianzan favor" bind:tap="favor" data-id="{{item.id}}" data-index="{{index}}" style="color: red;"></view> </view> <view wx:else="{{item.is_like==0}}"> <view class="iconfont icon-dianzan favor" bind:tap="favor" data-id="{{item.id}}" data-index="{{index}}" style="color: black;"></view> </view> </view> <view><image src="{{item.img}}"></image></view> </view>
wx.showToast不起作用?wx.showToast 在开发工具正常显示,安卓手机调试时不生效 _nullBack(res) { console.log(res,'11122') let str = '提示信息!' if(res.errmsg){ str = res.errmsg } wx.showToast({ title: str, icon: 'none', duration: 2000 }) this.data.SocketTask.close({ code: 1000, success() { console.log('正常手动关闭') }, }) setTimeout(() => { wx.navigateBack({ delta: 1, }) }, 2500) },
2022-11-27function fn(change,index=0){ change.map((item,key)=>{ if(key==index){ return item['hidden']=false,item['style']='now'; }else{ return item['hidden']=true,item['style']=''; } }) return{ change,index }; } module.exports = {fn}
share-element为何无法生效?调试版本2.16.1使用share-element,完全按照官方文档写了一个非常简单的demo依然无法实现效果? <share-element key="123" transform="true"> <view>123</view> </share-element> <button bindtap="test">xxx</button> <page-container show="{{show}}" transform="true" > <view class="page-wrap"> <share-element key="123" transform="true"> <view class="test">123</view> </share-element> </view> </page-container>
2022-11-20