除了swimlane pool之外,我能够正确检索所有形状。我尝试使用jointjs 0.9.5和0.9.3。他们两个都犯了类似的错误:
Uncaught Error: dia.ElementView: reference does not exists
@ joint_0.9.5.js:5286
joint.dia.ElementView.joint.dia.CellView.extend.positionRelative
@ joint_0.9.5.js:5286
使用jointjs 0.9.3会在此行显示错误
未捕获的TypeError:无法读取未定义的属性“bbox”
if (ref) {
// Get the bounding box of the reference element relative to the root `<g>` element.
bbox = V(this.findBySelector(ref)[0]).bbox(false, this.el);
}
我的形状定义如下:
joint.shapes.devs.Container = joint.shapes.devs.Model.extend(_.extend({}, joint.plugins.TooledModelInterface, {
markup:
[
'<g class="rotatable">',
'<g class="scalable">',
'<rect class="body"/>',
'</g>',
'<rect class="pool_header"/>',
'<text class="t"/>',
'<g class="inPorts"/>',
'<g class="outPorts"/>',
'<g class="moveTool"/>',
'<g class="resizeTool"/>',
'<g class="portsTool"/>',
'</g>'
].join(''),
defaults: joint.util.deepSupplement({
type: 'devs.TooledModel',
position: {x: 200, y: 100},
size: {width: 71, height: 625},
attrs:
{
'.body': {fill: '#ffffff', stroke: '#000000', width: 500, height: 200, 'pointer-events': 'stroke'},
'.pool_header': {fill: '#fff', stroke: '#000', width: 30, ref: '.body', 'ref-height': 1, 'pointer-events': 'visiblePainted'},
'.t': {transform: 'rotate(-90)', ref: '.pool_header', dx: '-0.1%', dy: '50%', 'x-alignment': 'middle', 'text-anchor': 'middle'},
rect: {stroke: '#000000', fill: '#EEEEEE', 'stroke-width': 2}, '.': {magnet: false},
'.inPorts circle': {type: 'input'},
'.outPorts circle': {type: 'output'},
'.port-body': {r: 3}
}
}, joint.shapes.devs.Model.prototype.defaults)
}
更新
我检查过很多次。只有从数据库检索时才会出现此问题,jointjs无法获取以下内容的边界框:
console.log(V(this.findBySelector(ref)[0]).bbox(false, this.el));
我手动检查了,这是错误。由于此错误,不显示池标题,并且形状本身看起来变形
答案 0 :(得分:0)
我认为这是因为&#39; .port-body&#39;它不在你的标记中。所以&#34; 参考&#34; (port-body)不存在于标记
中尝试删除port-body以及所有不在标记中的引用。
问候!