问题描述
在文档中,有人说:onMove(mover,leftTop,e)在每次移动通知期间调用;实际上应该移动节点;可以被覆盖。
但没有例子如何覆盖它(onMove)。有人可以扔几行代码来显示它是如何工作的?
谢谢。
不要指出 onMove
函数属于哪个dojo JavaScript类。但是,您有几种通用的方法来覆盖也适用于您的情况的函数。
1)使用。
假设JavaScript类名是 myClass
,可以使用
dojo.declare('anotherClass',myClass,{
onMove:function(mover,leftTop,e){}
});
2)使用。
dojo.extend(myClass,{
onMove:function(mover,leftTop,e){}
});
如果您只想覆盖单个实例的函数,请直接设置属性。 >
var obj = new myClass();
obj.onMove = function(){};
In docs it was said that:
onMove(mover, leftTop, e) called during every move notification; should actually move the node; can be overwritten.
but no example how to overwrite it (onMove). Can somebody throw several lines of code to show how it works?
Thanks.
You don't point out which dojo JavaScript class that the onMove
function belongs to. However, you have a couple of generic ways to override functions that also applies in your case.
1) Create a new subclass using dojo.declare
.
Suppose the JavaScript class name is myClass
, you can use
dojo.declare('anotherClass', myClass, {
onMove : function(mover, leftTop, e) {}
});
2) Change the class's prototype using dojo.extend
.
dojo.extend(myClass, {
onMove : function(mover, leftTop, e) {}
});
If you only want to override the function for a single instance, set the property directly.
var obj = new myClass();
obj.onMove = function() {};
这篇关于Dojo:如何使用自己的onMove事件(覆盖)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!