您好,咱们可以换个逻辑实现:
- flex.addEventListener(flex.hostElement, 'click', (e) => {
- let $hit = flex.hitTest(e)
- let $rowIndex = $hit.row
- let $colIndex = $hit.col
- if(Math.sign($rowIndex) === -1 || Math.sign($colIndex) === -1){
- return false
- } // 判断负数
- /* 显示(放大镜)帮助索引 */
- let rcCell = flex.getCellBoundingRect($rowIndex, $colIndex) // 单元格坐标
- let host = flex.hostElement;
- let hostLeft = host.getBoundingClientRect().left;
- let hostTop = host.getBoundingClientRect().top;
- let point = $hit.point;
- this.helpIndex = {
- left: rcCell.left + rcCell.width - hostLeft + 'px',
- top: rcCell.top - hostTop + 'px'
- }
- })
复制代码
附件是完整Demo。
|