From 28cebf9e4e1deee88a8f923dc71fb0167895cf4e Mon Sep 17 00:00:00 2001 From: sight <1453017105@qq.com> Date: Mon, 22 May 2023 00:42:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20form=20=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E6=97=B6=20checkbox=20=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=A8=A1=E7=89=88=E6=9C=AA=E6=AD=A3=E7=A1=AE=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/form.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/modules/form.js b/src/modules/form.js index 41428288..1c6ca300 100644 --- a/src/modules/form.js +++ b/src/modules/form.js @@ -690,6 +690,13 @@ layui.define(['lay', 'layer', 'util'], function(exports){ }())); var disabled = this.disabled; + if(!skins[skin]) skin = 'primary'; // 若非内置风格,则强制为默认风格 + var RE_CLASS = CLASS[skin] || CLASS.checkbox; + + // 替代元素 + var hasRender = othis.next('.' + RE_CLASS[0]); + hasRender[0] && hasRender.remove(); // 如果已经渲染,则Rerender + // 若存在标题模板,则优先读取标题模板 if(othis.next('[lay-checkbox]')[0]){ title = othis.next().html() || ''; @@ -697,14 +704,10 @@ layui.define(['lay', 'layer', 'util'], function(exports){ // 若为开关,则对 title 进行分隔解析 title = skin === 'switch' ? title.split('|') : [title]; - - if(!skins[skin]) skin = 'primary'; // 若非内置风格,则强制为默认风格 - var RE_CLASS = CLASS[skin] || CLASS.checkbox; if(typeof othis.attr('lay-ignore') === 'string') return othis.show(); // 替代元素 - var hasRender = othis.next('.' + RE_CLASS[0]); var reElem = $(['