mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:48:13 +08:00
feat:formula补充一些数组函数
This commit is contained in:
parent
4131d448d6
commit
70149e7829
@ -1008,6 +1008,7 @@ UNIQ([{a: '1'}, {b: '2'}, {a: '1'}], 'id')
|
||||
|
||||
* `obj:any` 对象或数组
|
||||
* `path:string` 路径
|
||||
* `defaultValue:any` 如果解析不到则返回该值
|
||||
|
||||
返回:`any` 结果
|
||||
|
||||
@ -1017,7 +1018,6 @@ UNIQ([{a: '1'}, {b: '2'}, {a: '1'}], 'id')
|
||||
|
||||
GET([0, 2, {name: 'amis', age: 18}], 1) 得到 2
|
||||
GET([0, 2, {name: 'amis', age: 18}], '2.name') 得到 'amis'
|
||||
GET([0, 2, {name: 'amis', age: 18}], '[2].name') 得到 'amis'
|
||||
GET({arr: [{name: 'amis', age: 18}]}, 'arr[0].name') 得到 'amis'
|
||||
GET({arr: [{name: 'amis', age: 18}]}, 'arr.0.name') 得到 'amis'
|
||||
GET({arr: [{name: 'amis', age: 18}]}, 'arr.1.name', 'not-found') 得到 'not-found'
|
||||
|
@ -1615,7 +1615,7 @@ export const doc: {
|
||||
},
|
||||
{
|
||||
name: "GET",
|
||||
description: "根据对象或者数组的path路径获取值。 如果解析 value 是 undefined 会以 defaultValue 取代\n\n示例:\n\nGET([0, 2, {name: 'amis', age: 18}], 1) 得到 2\nGET([0, 2, {name: 'amis', age: 18}], '2.name') 得到 'amis'\nGET([0, 2, {name: 'amis', age: 18}], '[2].name') 得到 'amis'\nGET({arr: [{name: 'amis', age: 18}]}, 'arr[0].name') 得到 'amis'\nGET({arr: [{name: 'amis', age: 18}]}, 'arr.0.name') 得到 'amis'\nGET({arr: [{name: 'amis', age: 18}]}, 'arr.1.name', 'not-found') 得到 'not-found'",
|
||||
description: "根据对象或者数组的path路径获取值。 如果解析 value 是 undefined 会以 defaultValue 取代\n\n示例:\n\nGET([0, 2, {name: 'amis', age: 18}], 1) 得到 2\nGET([0, 2, {name: 'amis', age: 18}], '2.name') 得到 'amis'\nGET({arr: [{name: 'amis', age: 18}]}, 'arr[0].name') 得到 'amis'\nGET({arr: [{name: 'amis', age: 18}]}, 'arr.0.name') 得到 'amis'\nGET({arr: [{name: 'amis', age: 18}]}, 'arr.1.name', 'not-found') 得到 'not-found'",
|
||||
example: "GET(arr, 2)",
|
||||
params: [
|
||||
{
|
||||
@ -1627,6 +1627,11 @@ export const doc: {
|
||||
type: "string",
|
||||
name: "path",
|
||||
description: "路径"
|
||||
},
|
||||
{
|
||||
type: "any",
|
||||
name: "defaultValue",
|
||||
description: "如果解析不到则返回该值"
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
|
@ -1962,13 +1962,13 @@ export class Evaluator {
|
||||
*
|
||||
* GET([0, 2, {name: 'amis', age: 18}], 1) 得到 2
|
||||
* GET([0, 2, {name: 'amis', age: 18}], '2.name') 得到 'amis'
|
||||
* GET([0, 2, {name: 'amis', age: 18}], '[2].name') 得到 'amis'
|
||||
* GET({arr: [{name: 'amis', age: 18}]}, 'arr[0].name') 得到 'amis'
|
||||
* GET({arr: [{name: 'amis', age: 18}]}, 'arr.0.name') 得到 'amis'
|
||||
* GET({arr: [{name: 'amis', age: 18}]}, 'arr.1.name', 'not-found') 得到 'not-found'
|
||||
*
|
||||
* @param {any} obj 对象或数组
|
||||
* @param {string} path 路径
|
||||
* @param {any} defaultValue 如果解析不到则返回该值
|
||||
* @namespace 其他
|
||||
* @example GET(arr, 2)
|
||||
* @returns {any} 结果
|
||||
|
Loading…
Reference in New Issue
Block a user