top属性设置消息距离顶部的位置,单位为 px',
- 'en-US': `Use the top property to set the distance from the top of the message in units of px. `
+ 'zh-CN': '通过top属性设置模态框距离顶部的位置',
+ 'en-US': 'Use the top property to set the distance from the top of the modal.'
},
codeFiles: ['message-top.vue']
},
diff --git a/packages/renderless/src/modal/index.ts b/packages/renderless/src/modal/index.ts
index ff56aa19a3..7b00875ae2 100644
--- a/packages/renderless/src/modal/index.ts
+++ b/packages/renderless/src/modal/index.ts
@@ -61,9 +61,14 @@ export const computedBoxStyle =
return {}
}
+ let top = ''
let width: string | number = ''
let height: string | number = ''
+ if (props.type === 'alert' || props.type === 'confirm') {
+ top = typeof props.top === 'number' ? `${props.top}px` : props.top
+ }
+
if (props.width) {
width = isNaN(props.width as number) ? props.width : `${props.width}px`
}
@@ -72,7 +77,7 @@ export const computedBoxStyle =
height = isNaN(props.height as number) ? props.height : `${props.height}px`
}
- return { width, height }
+ return { top, width, height }
}
export const watchValue =