mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:48:55 +08:00
优化 default filter 支持其他类型定义
This commit is contained in:
parent
ce899390dd
commit
44fce36608
@ -176,17 +176,17 @@ export const filters: {
|
|||||||
},
|
},
|
||||||
url_encode: input => encodeURIComponent(input),
|
url_encode: input => encodeURIComponent(input),
|
||||||
url_decode: input => decodeURIComponent(input),
|
url_decode: input => decodeURIComponent(input),
|
||||||
default: (input, ...rest) => input || rest.map((item: any) => {
|
default: (input, defaultValue) => input || (() => {
|
||||||
try {
|
try {
|
||||||
if (item === 'undefined') {
|
if (defaultValue === 'undefined') {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return JSON.parse(item);
|
return JSON.parse(defaultValue);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return item;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}).join(":"),
|
})(),
|
||||||
join: (input, glue) => (input && input.join ? input.join(glue) : input),
|
join: (input, glue) => (input && input.join ? input.join(glue) : input),
|
||||||
split: (input, delimiter = ",") =>
|
split: (input, delimiter = ",") =>
|
||||||
typeof input === "string" ? input.split(delimiter) : input,
|
typeof input === "string" ? input.split(delimiter) : input,
|
||||||
|
Loading…
Reference in New Issue
Block a user