This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

优化layer

old
宇天 2021-06-10 23:35:03 +08:00
parent 5cf6d277cb
commit 9d45ca3cbf
1 changed files with 13 additions and 8 deletions

View File

@ -336,13 +336,13 @@ export default class Layer {
switch (val) { switch (val) {
case 'alert': case 'alert':
while (btns.length > 1) { while (btns.length > 1) {
btns.splice(0, 1) btns.shift()
} }
break break
case 'confirm': case 'confirm':
case 'prompt': case 'prompt':
while (btns.length > 2) { while (btns.length > 2) {
btns.splice(0, 1) btns.shift()
} }
break break
case 'toast': case 'toast':
@ -715,17 +715,22 @@ function _layer(opt) {
} }
Object.assign(_layer, { Object.assign(_layer, {
alert(content, title = lang.TITLE) { alert(content, title = lang.TITLE, btns = false) {
if (typeof title === 'object') {
btns = title
title = lang.TITLE
}
return this({ return this({
type: 'alert', type: 'alert',
title, title,
content, content,
mask: true mask: true,
btns
}) })
}, },
confirm(content, title = lang.TITLE, intercept) { confirm(content, title = lang.TITLE, btns = false) {
if (typeof title === 'function') { if (typeof title === 'object') {
intercept = title btns = title
title = lang.TITLE title = lang.TITLE
} }
return this({ return this({
@ -733,7 +738,7 @@ Object.assign(_layer, {
title, title,
content, content,
mask: true, mask: true,
intercept btns
}) })
}, },
prompt(title = lang.TITLE, defaultValue = '', intercept) { prompt(title = lang.TITLE, defaultValue = '', intercept) {