如何修复错误'对象没有't支持属性或方法'getScreenCTM''在Inter

How to fix error 'Object doesn't support property or method 'getScreenCTM'' in Internet explorer broweser using D3 tip.js

本文关键字:属性 方法 getScreenCTM 支持 Inter 错误 何修复 对象      更新时间:2023-09-26

我使用的是D3 tip.js,

function getScreenBBox() {
var targetel   = target || d3.event.target,
    bbox       = {},
    matrix     = targetel.getScreenCTM(),
    tbbox      = targetel.getBBox(),
    width      = tbbox.width,
    height     = tbbox.height,
    x          = tbbox.x,
    y          = tbbox.y,
    scrollTop  = document.documentElement.scrollTop || document.body.scrollTop,
    scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
}

我在Internet Explorer浏览器中的Internet Explorer Object doesn't support property or method 'getScreenCTM'中收到此错误。在鼠标进入树节点时,工具提示我们显示,在鼠标离开时,隐藏工具提示。但刀尖的显示位置没有改变。

从实际意义上讲,如果您的项目使用编译,您可能会尝试安装polyfill包,该包提供ES5兼容性

npm i --save core-js

yarn add core-js

然后在项目的入口点顶部添加

import 'core-js'

目前,core-js-polyfill库是使跨浏览器支持的最简单方法

对我来说,这个语法运行良好

  1. "d3":"5.4.0"
  2. "d3提示":"^0.9.1"

.on('mouseover',(d,i,n)=>tip.show(d,n[i]))