omiu - update dialog

This commit is contained in:
张磊 2019-04-01 11:07:28 +08:00
parent bab5a924c4
commit d14d9bfbde
2 changed files with 29 additions and 1 deletions

View File

@ -20,6 +20,7 @@
top: 20%;
border-radius: 4px;
text-align: center;
padding: 10px;
}
h1 {

View File

@ -1,4 +1,4 @@
import { define, WeElement } from 'omi'
import { define, WeElement, render } from 'omi'
import style from './_index.css'
define('o-dialog', class extends WeElement {
@ -44,3 +44,30 @@ define('o-dialog', class extends WeElement {
)
}
})
let dialog = {},
dom
dialog.alert = function (msg) {
if (dom) {
document.body.removeChild(dom)
}
dom = render(<o-dialog
onConfirm={closeAlert}
width={400}
show={true}
type='alert'
title='提示'
msg={msg}
confirmText='确定'
/>, 'body')
}
function closeAlert() {
if (dom) {
document.body.removeChild(dom)
dom = null
}
}
export default dialog