- 点击元素e.currentTarget.id问题?
[代码] [代码][代码]wx.createSelectorQuery().selectAll([代码][代码]'#jia'[代码][代码]).boundingClientRect((res) => {[代码][代码] [代码][代码]for[代码][代码]([代码][代码]var[代码] [代码]i=0;i<res.length;i++){[代码] [代码] if(e.currentTarget.daataset.id==res[i].dataset.id){ [代码] this.rt=res[i].top this.rl=res[i].left }[代码][代码] [代码] [代码] [代码]}[代码] <view bindtap="jia" class="standard" data-id="{{goods.id}}" id="jia"></view> [图片]发现就是data-id的值有重复的,之前是让e.currentTarget.daataset.id==res[i].dataset.id取出相应的值,结果有两个,不是唯一的 然后怎么根据我点击的“+”来取到相应的值,来做判断
2019-10-25 - SelectorQuery问题?
[图片]我这是循环出来的。然后就是怎么通过SelectorQuery获取到其他“+”组件的位置。这个只能获取第一个
2019-10-22 - 点击商品飞入购物车问题?
就是像美团外卖一样,点击物品飞入购物车,不管点击“+”哪里 那个红点都是从同一个位置飞入购物车[图片] [代码]//点击点的坐标[代码][代码]this[代码][代码].finger[[代码][代码]'x'[代码][代码]] = e.touches[[代码][代码]"0"[代码][代码]].clientX;[代码][代码] [代码][代码]this[代码][代码].finger[[代码][代码]'y'[代码][代码]] = e.touches[[代码][代码]"0"[代码][代码]].clientY;[代码] [代码]//动画[代码][代码] [代码][代码]startAnimation: [代码][代码]function[代码][代码]() {[代码][代码] [代码][代码]var[代码] [代码]index = 0,[代码][代码] [代码][代码]that = [代码][代码]this[代码][代码],[代码][代码] [代码][代码]bezier_points = that.linePos[[代码][代码]'bezier_points'[代码][代码]];[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]hide_good_box: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]bus_x: that.finger[[代码][代码]'x'[代码][代码]],[代码][代码] [代码][代码]bus_y: that.finger[[代码][代码]'y'[代码][代码]][代码][代码] [代码][代码]})[代码][代码] [代码][代码]index = bezier_points.length;[代码][代码] [代码][代码]this[代码][代码].timer = setInterval([代码][代码]function[代码][代码]() {[代码][代码] [代码][代码]index--;[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]bus_x: bezier_points[index][[代码][代码]'x'[代码][代码]],[代码][代码] [代码][代码]bus_y: bezier_points[index][[代码][代码]'y'[代码][代码]][代码][代码] [代码][代码]})[代码][代码] [代码][代码]if[代码] [代码](index<1) {[代码][代码] [代码][代码]clearInterval(that.timer);[代码][代码] [代码][代码]// that.addGoodToCartFn();[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]hide_good_box: [代码][代码]true[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}, 20);[代码][代码] [代码][代码]},[代码]
2019-10-22