From 9d45ca3cbf699916b13ca7f9a6c3cafa5663201d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Thu, 10 Jun 2021 23:35:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96layer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layer/index.wc | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/layer/index.wc b/src/layer/index.wc index 9327938..d92db6f 100644 --- a/src/layer/index.wc +++ b/src/layer/index.wc @@ -336,13 +336,13 @@ export default class Layer { switch (val) { case 'alert': while (btns.length > 1) { - btns.splice(0, 1) + btns.shift() } break case 'confirm': case 'prompt': while (btns.length > 2) { - btns.splice(0, 1) + btns.shift() } break case 'toast': @@ -715,17 +715,22 @@ function _layer(opt) { } 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({ type: 'alert', title, content, - mask: true + mask: true, + btns }) }, - confirm(content, title = lang.TITLE, intercept) { - if (typeof title === 'function') { - intercept = title + confirm(content, title = lang.TITLE, btns = false) { + if (typeof title === 'object') { + btns = title title = lang.TITLE } return this({ @@ -733,7 +738,7 @@ Object.assign(_layer, { title, content, mask: true, - intercept + btns }) }, prompt(title = lang.TITLE, defaultValue = '', intercept) {