0
我能夠正確檢索除swimlane pool以外的所有形狀。我試着用jointjs 0.9.5和0.9.3。他們都拋出類似的錯誤:從jointjs的數據庫中檢索形狀時出錯
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在此行給出了錯誤
遺漏的類型錯誤:未定義
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);
}
無法讀取屬性「BBOX」我的形狀被定義像這樣:
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)
}
更新:
我檢查了很多次。
console.log(V(this.findBySelector(ref)[0]).bbox(false, this.el));
我手動檢查它,這裏是錯誤:只有whlie從數據庫中檢索,jointjs是不是能夠得到以下的邊框會出現此問題。由於此錯誤,池標題不顯示,並且形狀本身看起來扭曲