关于居中
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 })
});
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。