关于tab居中点击元素居中(小程序)//获取访客设备的宽度constclientWidth=dd.getSystemInfoSync().windowWidth/2;//获取节点组合constnodes=dd.createSelectorQuery().selectAll('.tabs.item');handleTap(){const{index}=e.target.dataset;const{offsetLeft}=e.currentTarget;const填充=96;//框的默认边距nodes.boundingClientRect().exec(rect=>{const{width}=rect[0][index];constscrollLeft=offsetLeft-this.clientWidth/2+(width/2)-PADDINGthis.setData({scrollLeft})});}
