我必须从 Dojo 继承 Mover 类,因为如果我不这样做就会出现图形错误,因此必须更改某个功能。
错误:win.doc未定义
define(["dojo/_base/declare", "dojo/dnd/Mover", "dojo/_base/event", "dojo/dom-geometry","dojo/window"],function(declare,Mover, event,domGeom,win){
console.log("myMover");
return declare([Mover],{
onFirstMove: function(e){
// summary:
// makes the node absolute; it is meant to be called only once.
// relative and absolutely positioned nodes are assumed to use pixel units
var s = this.node.style, l, t, h = this.host;
switch(s.position){
case "relative":
case "absolute":
// assume that left and top values are in pixels already
l = Math.round(parseFloat(s.left)) || 0;
t = Math.round(parseFloat(s.top)) || 0;
break;
default:
var m = domGeom.getMarginBox(this.node);
s.position = "absolute"; // enforcing the absolute mode
// event.pageX/pageY (which we used to generate the initial
// margin box) includes padding and margin set on the body.
// However, setting the node's position to absolute and then
// doing domGeom.marginBox on it *doesn't* take that additional
// space into account - so we need to subtract the combined
// padding and margin. We use getComputedStyle and
// _getMarginBox/_getContentBox to avoid the extra lookup of
// the computed style.
var b = win.doc.body; // Firebug is telling me win.doc is undefined
var bs = domStyle.getComputedStyle(b);
var bm = domGeom.getMarginBox(b, bs);
var bc = domGeom.getContentBox(b, bs);
l = m.l - (bc.l - bm.l);
t = m.t - (bc.t - bm.t);
break;
}
this.marginBox.l = l - this.marginBox.l;
this.marginBox.t = t - this.marginBox.t;
if(h && h.onFirstMove){
h.onFirstMove(this, e);
}
// Disconnect touch.move that call this function
this.events.shift().remove();
},
});
});
谁能告诉我解决办法吗?
问候 九月
最佳答案
dojo/window
模块和 dojo/_base/window
模块之间存在差异。只有 dojo/_base/window
模块具有属性 doc
.
例如:
require([ "dojo/_base/window", "dojo/window" ], function(win, win2) {
var myDoc = win.doc; // Returns current document
var myDoc2 = win2.doc; // Returns undefined
});
关于javascript - Dojo win.doc 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23781803/