Javascript 如何修复错误';对象没有';t支持属性或方法';getScreenCTM'';在Internet explorer浏览器中使用D3 tip.js
我使用的是D3 tip.jsJavascript 如何修复错误';对象没有';t支持属性或方法';getScreenCTM'';在Internet explorer浏览器中使用D3 tip.js,javascript,d3.js,Javascript,D3.js,我使用的是D3 tip.js function getScreenBBox() { var targetel = target || d3.event.target, bbox = {}, matrix = targetel.getScreenCTM(), tbbox = targetel.getBBox(), width = tbbox.width, height = tbbox.height,
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浏览器中的属性或方法“getScreenCTM”
。鼠标进入树节点时工具提示us显示,鼠标离开时工具提示隐藏。但刀尖的显示位置不变 对我来说,这种语法很好用
.on('mouseover',(d,i,n)=>tip.show(d,n[i])从实际意义上讲,如果您在项目中使用编译,您可以尝试安装提供ES5兼容性的polyfill软件包
npm i --save core-js
或
然后添加到项目入口点的顶部
import 'core-js'
目前,实现跨浏览器支持的最简单方法是什么哪个版本的IE?仅在Internet explorer 11中的@Mark Getting error'对象不支持属性或方法“getScreenCTM”中受支持。您确定IE未在“兼容模式”下运行吗?转到开发人员工具,仿真选项卡,并查看文档模式。另外,请确保在HTML页面的标题部分包含
。@标记已解决的错误,因为变量targetel在Internet explorer中获取了不同的SVG元素(即SVGTspanElement和SVGTextElement)。为了澄清问题,IE的SVGTspanElement没有getScreenCTM()函数。您必须在父层次结构中找到第一个SVGTextElement并在其上使用函数。
import 'core-js'