wxml部分代码 <form bindsubmit="onSubmit"> <view class="content"> <view > <view class="content-align-left"> <van-cell-group> <van-field name='pv_long' value="{{ pv_long }}" label="组件长度" placeholder="请填写组件长度" border="{{ false }}" /> </van-cell-group> </view> <view class="content-align-right"> <van-dropdown-menu> <van-dropdown-item value="{{ value1 }}" options="{{ option1 }}" bindchange="p_long" /> </van-dropdown-menu> </view> </view> <view> <view class="content-align-left"> <van-cell-group> <van-field name='pv_width' border="{{ false }}" value="{{ pv_width }}" label="组件宽度" placeholder="请填写组件宽度" /> </van-cell-group> </view> <view class="content-align-right"> <van-dropdown-menu> <van-dropdown-item value="{{ value2 }}" options="{{ option2 }}" bindchange="p_width" /> </van-dropdown-menu> </view> </view> <view> <view class="content-align-left"> <van-cell-group> <van-field name='pv_height' border="{{ false }}" value="{{ pv_height }}" label="组件高度" placeholder="请填写组件高度" /> </van-cell-group> </view> <view class="content-align-right"> <van-dropdown-menu> <van-dropdown-item value="{{ value3 }}" options="{{ option3 }}" bindchange="p_height" /> </van-dropdown-menu> </view> </view> 。 。。。 <view > <view class="content-align-left"> <van-cell-group > <van-field name='pv_glass_price' value="{{ pv_glass_price }}" label="玻璃单价" placeholder="请输入单价" bindblur='p_glass_p'/> </van-cell-group> </view> <view class="content-align-right"> <van-dropdown-menu> <van-dropdown-item value="{{ value10 }}" options="{{ option10 }}" bindchange="p_glass_price"/> </van-dropdown-menu> </view> </view>
请问在在开发工具中调试速度正常,后面用真机调试速度较慢是什么问题?请技术高手帮忙看看。使用的组件数量接近三四十个,几乎都需要事件响应。输入框离开时触发,下拉选择也触发。使用真机调试下拉框弹出来的数据的比较慢 [图片] js部分代码: p_width: function (event) { this.data.p_width = event.detail let ab = ((this.data.p_long + this.data.p_width) * 2) / 1000 / 13 * 9 this.setData({ pv_width: event.detail, pv_silica_gel: ab.toPrecision(1) }) }, p_long: function (event) { this.data.p_long = event.detail this.setData({ pv_long: event.detail }) }, p_height: function (event) { this.setData({ pv_height: event.detail }) }, p_pailei_a: function (event) { this.data.p_pailei_a = event.detail this.setData({ pv_pailei_a: event.detail }) }, p_pailei_b: function (event) { this.data.p_pailei_b = event.detail this.setData({ pv_pailei_b: event.detail }) }, p_battery_long: function (event) { this.data.p_battery_long = event.detail this.setData({ pv_battery_long: event.detail }) }, p_battery_width: function (event) { this.data.p_b_width = event.detail let a = event.detail / this.data.p_battery_long * this.data.p_pailei_a * this.data.p_pailei_b let ab = a * 0.01 * 4.5 this.data.aa = a this.setData({ pv_battery_width: event.detail, pv_djzp_waat: a.toPrecision(2), pv_other: ab.toPrecision(2) }) }, 。。。。。。 。。。略部分代码。。。 。。。。。 p_welding_price: function (event) { let jj = (this.data.p_b_width) * 1.8 * (this.data.p_pailei_a) * (this.data.p_pailei_b + 1) * 5 / 1000 * 0.0022 * event.detail // console.log(jj) this.setData({ pv_welding_price: event.detail, pv_welding: jj.toPrecision(2) }) }, p_welding_p: function (event) { let kk = (this.data.p_b_width) * 1.8 * (this.data.p_pailei_a) * (this.data.p_pailei_b + 1) * 5 / 1000 * 0.0022 * event.detail.value this.setData({ pv_welding: kk.toPrecision(2) }) }, p_bus_price: function (event) { this.setData({ pv_bus_price: event.detail }) }, p_border_price: function (event) { let ll = ((this.data.p_long + this.data.p_width) * 2 * event.detail)/1000 // console.log(jj) this.setData({ pv_border_price: event.detail, pv_border: ll.toPrecision(2) }) }, p_border_p: function (event) { let mm = ((this.data.p_long + this.data.p_width) * 2 * event.detail.value)/1000 this.setData({ pv_border: mm.toPrecision(2) }) }, 在开发工具中调试速度还算正常,只要上真机调试速度就慢了,,, wxml部分代码
2020-02-15//index.js const app = getApp() const db = wx.cloud.database() Page({ data: { list:[], tops:[], }, addCart(e) { //购物车功能 //事件传递数据的一种方法 const {item} = e.currentTarget.dataset //把商品的所有信息全部放到购物车里面,同时还要增加一个数量的显示 //先查询数据库中有没有这个数据,如果有继续加1,如果没有单独赋值为1 const i = app.globalData.carts.findIndex(v => v._id == item._id) if (i > -1) { //数量加1 app.globalData.carts[i].num += 1 } else { item.num = 1 app.globalData.carts.push(item) } }, onPullDownRefresh(){ this.page = 0 this.getList(true) }, onReachBottom(){ this.page +=1 this.getList() }, redirectToDetail(event,x){ wx.navigateTo({ url: '/pages/detail/detail?id='+event.currentTarget.id, }) console.log(event.currentTarget.id) }, toDetail(e){ const id = e.currentTarget.id wx.navigateTo({ url: '/pages/detail/detail?id='+id, }) //console.log(id) }, getList(isInit){ const PAGE= 5 wx.showLoading({ title: '加载中', }) db.collection('emall').skip(this.page * PAGE).limit(PAGE).get({ success: res =>{ console.log('xx',res.data) if (isInit){ this.setData({ list: res.data }) } else { this.setData({ list:this.data.list.concat(res.data) }) wx.stopPullDownRefresh() } wx.hideLoading() } }) }, getTop(){//首页效果轮播图 db.collection('emall').orderBy('count','desc').limit(4).get({ success:res=>{ console.log(res.data) this.setData({ tops:res.data }) } }) //取emall中的内容count的值,进行降序显示,只显示4条记录。 }, onLoad() { this.page = 0 this.getList(true) this.getTop() } })
购物车加入问题?参考https://cloud.tencent.com/edu/learning/learn-1482-8557 里面的教程,购物车加1的问题。 谢谢解答! [图片] const app = getApp() const db = wx.cloud.database() Page({ data: { list:[], tops:[] }, addCart(e) { const {item} = e.currentTarget.dataSet const i = app.globalData.carts.findIndex(v => v._id == item._id) if (i>-1) { //数量加1 app.globalData.carts[i].num += 1 } else { item.num = 1 app.globalData.carts.push(item) } },
2020-02-11