fix(editor): 添加组件默认添加到视窗中间,如果组件初始化height不是数值,则当0处理

This commit is contained in:
roymondchen 2022-05-31 21:05:22 +08:00 committed by jia000
parent 805339422a
commit 663d7cee9f

View File

@ -142,9 +142,13 @@ export const toRelative = (node: MNode) => {
const setTop2Middle = (node: MNode, parentNode: MNode, stage: StageCore) => {
const style = node.style || {};
const height = style.height || 0;
let height = style.height || 0;
if (!stage || typeof style.top !== 'undefined' || !parentNode.style || !isNumber(height)) return style;
if (!stage || typeof style.top !== 'undefined' || !parentNode.style) return style;
if (!isNumber(height)) {
height = 0;
}
const { height: parentHeight } = parentNode.style;