【发布时间】:2018-08-09 22:12:23
【问题描述】:
创建文本节点后:
const text = new Konva.Text({
x: stage.width() / 2,
y: stage.height() / 2,
width: 200,
fontSize: 30,
height: 30,
fill: 'green',
text: 'Simple text'
});
如果 height 值等于 fontSize 值,则函数 stage.toJSON() 不返回 height 参数:
[object Object] {
attrs: [object Object] { ... },
children: [[object Object] {
attrs: [object Object] { ... },
children: [[object Object] {
attrs: [object Object] {
fill: "green",
fontSize: 30,
text: "Simple text",
width: 200
},
className: "Text"
}],
className: "Layer"
}],
className: "Stage"
}
这是一个 jsbin:http://jsbin.com/hikobiceji/1/edit?html,js,console
但如果 height 和 fontSize 不相等:
const text = new Konva.Text({
x: stage.width() / 2,
y: stage.height() / 2,
width: 200,
fontSize: 30,
height: 30.01,
fill: 'green',
text: 'Simple text'
});
然后 height 参数存在:
[object Object] {
attrs: [object Object] { ... },
children: [[object Object] {
attrs: [object Object] { ... },
children: [[object Object] {
attrs: [object Object] {
fill: "green",
fontSize: 30,
height: 30.01,
text: "Simple text",
width: 200
},
className: "Text"
}],
className: "Layer"
}],
className: "Stage"
}
【问题讨论】:
标签: konvajs