浏览器有鼠标按下事件
document.onmousedown
事件是依赖于DOM ,微信小程序有相似的事件。就是bind:touchend
下面这里是mpvue用法
<!--原生 <view bind:touchend="touchEnd()">按下</view>-->
<div class="item_info" @touchend="touchEnd"><!--touchstart相当于onmousedown-->
<div v-for="(item, i) in List" :key="i" wx:key="i">
<item :item="item">这里显示每一个元素模块</item>
</div>
</div>
这里使用
query.select('#the-id').boundingClientRect()
可以获取元素距屏幕左侧的距离
touchEnd() {
let _that = this;
const query = wx.createSelectorQuery();
query.select(".item_info").boundingClientRect();
query.exec(function(res) {
console.log(res[0].left)//获取元素距左侧距离
});
};