@neatui/nuxt 1.5.3 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -189,12 +189,17 @@
|
|
|
189
189
|
const processInput = (value: any) => {
|
|
190
190
|
let processedArray: any[] = [];
|
|
191
191
|
|
|
192
|
+
// 处理 null 或 undefined,转换为空字符串
|
|
193
|
+
if (value === null || value === undefined) {
|
|
194
|
+
return [];
|
|
195
|
+
}
|
|
196
|
+
|
|
192
197
|
if (typeof value === 'string') {
|
|
193
198
|
state.originalType = 'string';
|
|
194
199
|
processedArray = value.trim() ? (value.includes(',') ? value.split(',').map((s: string) => s.trim()) : [value]) : [];
|
|
195
200
|
} else {
|
|
196
201
|
state.originalType = 'array';
|
|
197
|
-
processedArray = value
|
|
202
|
+
processedArray = Array.isArray(value) ? value : [];
|
|
198
203
|
}
|
|
199
204
|
|
|
200
205
|
// 过滤掉在options中不存在的值
|
|
@@ -240,7 +245,7 @@
|
|
|
240
245
|
};
|
|
241
246
|
// 选中
|
|
242
247
|
const select = (item: any) => {
|
|
243
|
-
const s = [...state.processedValue];
|
|
248
|
+
const s = [...(state.processedValue || [])];
|
|
244
249
|
// s?.indexOf(item) !== -1 ? s?.splice(s?.indexOf(item), 1) : s?.push(item);
|
|
245
250
|
if (s?.indexOf(item) !== -1) {
|
|
246
251
|
s?.splice(s?.indexOf(item), 1);
|