美文网首页
getBoundingClientRect 返回 0

getBoundingClientRect 返回 0

作者: 苍老师的眼泪 | 来源:发表于2022-06-18 23:30 被阅读0次
        this.rect = this.canvas.getBoundingClientRect()
        console.log(this.rect)
        this.show_qm_panel = false

如果dom的display是false的话,getBoundingClientRect是会返回0的
变通的方法是先让它显示,然后获取到 getBoundingClientRect 的值后随即隐藏

相关文章

网友评论

      本文标题:getBoundingClientRect 返回 0

      本文链接:https://www.haomeiwen.com/subject/xcilvrtx.html