使用 JointJS 获取论文的 width/height

Get the width/height of paper using JointJS

我通过移动模型来调整纸张大小:

paper.on('cell:pointermove', 
function(cellView, evt, x, y) { 
    if((x+cellView.model.prop('size/width'))>=650 &&(y+cellView.model.prop('size/height'))>=200)
    paper.setDimensions(x+cellView.model.prop('size/width'), y+cellView.model.prop('size/height'));
}

有没有办法像element.prop(properties)一样改变纸张的属性?

你可以用paper.options.widthpaper.options.height得到论文的width/height。 Paper 是一种视图,而不是模型,因此它没有 set()/get()/prop()/attr() 方法,但您始终可以像存储任何其他方法一样向其存储属性如果需要,请反对:paper.foo = 'bar'

你为什么不打电话给 paper.fitToContent()