From 32916cc7da75b5c33801bafea7a5374b3a54b84f Mon Sep 17 00:00:00 2001 From: morning-star <26325820+Sight-wcg@users.noreply.github.com> Date: Thu, 15 May 2025 10:32:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(form-select):=20=E4=BF=AE=E5=A4=8D=20option?= =?UTF-8?q?=20=E4=B8=A4=E7=AB=AF=E7=9A=84=20Unicode=20=E7=A9=BA=E6=A0=BC(U?= =?UTF-8?q?+00A0)=E8=A2=AB=E5=8E=BB=E9=99=A4=E7=9A=84=E9=97=AE=E9=A2=98=20?= =?UTF-8?q?(#2676)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(form-select): 修复 option 两端的 Unicode 空格(U+00A0)被去除的问题 * update * update * fix --- src/modules/form.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/modules/form.js b/src/modules/form.js index 8ed766e2..3923f54d 100644 --- a/src/modules/form.js +++ b/src/modules/form.js @@ -500,7 +500,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){ // 未查询到相关值 if(none){ - initValue = $(select[0].options[selectedIndex]).text(); // 重新获得初始选中值 + initValue = $(select[0].options[selectedIndex]).prop('text'); // 重新获得初始选中值 // 如果是第一项,且文本值等于 placeholder,则清空初始值 if(selectedIndex === 0 && initValue === input.attr('placeholder')){ @@ -706,7 +706,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){ input.on('input propertychange', layui.debounce(search, 50)).on('blur', function(e){ var selectedIndex = select[0].selectedIndex; - initValue = $(select[0].options[selectedIndex]).text(); // 重新获得初始选中值 + initValue = $(select[0].options[selectedIndex]).prop('text'); // 重新获得初始选中值 // 如果是第一项,且文本值等于 placeholder,则清空初始值 if(selectedIndex === 0 && initValue === input.attr('placeholder')){ @@ -728,6 +728,17 @@ layui.define(['lay', 'layer', 'util'], function(exports){ if(othis.hasClass(DISABLED)) return false; + // 将新增的 option 元素添加到末尾 + if(isCreatable && othis.hasClass(CREATE_OPTION)){ + var optionElem = $('