Skip to content

Drag 微信小程序运行报错 TypeError: _a2.getBoundingClientRect is not a function #2738

@webcolplay

Description

@webcolplay

NutUI React 包名

@nutui/nutui-react

NutUI React 版本号

2.7.0

平台

weapp

重现链接

https://github.com/jdf2e/nutui-react/blob/next/src/packages/drag/drag.taro.tsx#L71

重现步骤

日志报错 TypeError: _a2.getBoundingClientRect is not a function 拖动没有效果,绑定事件都能触发

  const getInfo = async () => {
    const el = myDrag.current
    if (el) {
      const { top, left, bottom, right } = boundary
      const { screenWidth, windowHeight } = getSystemInfoSync()
      const { width, height } = await getRectByTaro(dragRef.current)
     # 下面这行代码是否多余
    //  dragRef.current?.getBoundingClientRect()
      createSelectorQuery()
        .select(`.${className}`)
        .boundingClientRect((rec: any) => {
          setBoundaryState({
            top: -rec.top + top,
            left: -rec.left + left,
            bottom: windowHeight - rec.top - bottom - Math.ceil(height),
            right: screenWidth - rec.left - right - Math.ceil(width),
          })

          middleLine.current =
            screenWidth - rec.width - rec.left - (screenWidth - rec.width) / 2
        })
        .exec()
    }
  }

期望的结果是什么?

能够正常拖动

实际的结果是什么?

无法拖动

环境信息

No response

其他补充信息

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions