Dojo marginBox 返回不同的值
任何人都可以指导我有什么区别 this.marginBox 和 dojo.marginBox(this.node)
我对这两个返回不同值的情况感到困惑。
Anyone can guide me what's the difference between
this.marginBox
and
dojo.marginBox(this.node)
I'm confusing with this two where they return different value.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您返回的两个值是什么? (我已经有一段时间没有使用dojo了,但我似乎记得其中一个包括padding,另一个不包括?)
What are the two values you're getting back? (I haven't used dojo for a while, but I seem to remember one of them including padding and the other not?)
Dojo 只提供了一个 dojo.marginBox() 方法 — 我不知道 Dojo 提供了任何类型的原型或 mixin 来启用 this.marginBox 方法。换句话说,只有
dojo.marginBox(this.node)
是正确的。如果您提供这些方法为您返回的内容的示例,将会有所帮助。
我希望:
在大多数情况下返回未定义。但是,如果您尝试像这样分配给
this.marginBox
:那么将来对
this.marginBox
的调用将返回10
...它可能看起来它正在做一些事情,但它与 Dojo 或 CSS 无关,只会返回您输入的内容...不是很有用!Dojo only provides a
dojo.marginBox()
method — I am not aware of Dojo providing any kind of prototype or mixin that enables athis.marginBox
method. In other words, onlydojo.marginBox(this.node)
is correct.It would have helped if you provided examples of what those methods are returning for you.
I would expect:
to return undefined in most circumstances. However if you have tried to assign to
this.marginBox
like this:then future calls to
this.marginBox
would return10
... it might look like it is doing something, but it's got nothing to do with Dojo or CSS and will just return what you put in... not very useful!我在使用 dojo.marginBox 时会非常小心,我在浏览有关它的问题时发现了以下内容:
https://bugs.dojotoolkit.org/ticket/12492
不幸的是,dojo 团队不会解决这个问题,因为方法
dojo.marginBox(..)
不适用于隐藏节点,引用票证“在隐藏节点上调用时行为未定义”。我做了什么,我检查了节点的 clientWidth / Height。
I would be very careful in using dojo.marginBox, I was browsing around an issue about it and I found the following:
https://bugs.dojotoolkit.org/ticket/12492
unfortunately the dojo team won't fix the problem because the method
dojo.marginBox(..)
will not work for hidden nodes, quoting the ticket "the behavior is undefined when called on hidden nodes".What I did I checked the node's clientWidth / Height.