对于居中
tab 点击元素居中(小程序)
// 获取客设施宽度
const clientWidth = dd.getSystemInfoSync().windowWidth / 2;
// 获取节点联合
const nodes = dd.createSelectorQuery().selectAll( '.tabs .item');
handleTap(){const { index} = e.target.dataset;
const {offsetLeft} = e.currentTarget;
const PADDING = 96; // 盒子默认边距
nodes.boundingClientRect().exec( rect => {const { width} = rect[0][index];
const scrollLeft = offsetLeft - this.clientWidth / 2 + (width / 2) - PADDING
this.setData({scrollLeft})
});
}