如何修复Window.getComputedStyle不是对象错误

Nom*_*omi 13 javascript jquery drag-and-drop jquery-ui getcomputedstyle

我试图在https://github.com/desandro/draggabilly上使用draggabilly

它在html中工作正常.现在,当我试图在wordpress中添加它.我在firebug控制台中遇到以下错误.

TypeError: Argument 1 of Window.getComputedStyle is not an object.
return s.getComputedStyle(t, null)
Run Code Online (Sandbox Code Playgroud)

这是js文件的链接 http://draggabilly.desandro.com/draggabilly.pkgd.min.js

小智 0

我在使用 IE8 测试我的项目时收到此错误:最后很明显,此方法不适用于 IE 8!

Error: Object doesn't support this property or method at: http://...
Run Code Online (Sandbox Code Playgroud)

我收到了支持此方法的 FF 的错误,但我忘记更改window为我的框架窗口对象!

console.log(getComputedStyle(window.document.querySelector('.tip > .tip.top'), ':after').getPropertyValue('left'));
TypeError: Argument 1 of Window.getComputedStyle is not an object.
at: http://...
Run Code Online (Sandbox Code Playgroud)

请注意,即使您的window对象正常但不会querySelector返回任何内容,也会弹出上述错误!(我怀疑这是你的情况)。