📱🚀 🧩 Cross Device & High Performance Normal Form/Dynamic(JSON Schema) Form/Form Builder -- Support React/React Native/Vue 2/Vue 3
11.26k
stars
1.46k
forks
source link
[Feature Request] FormPath 支持数组通配的路径解析与数据操作 #3881
Closed
dominicleo closed 1 year ago
What problem does this feature solve?
支持数组通配的路径解析与数据操作
What does the proposed API look like?
路径解析支持数组通配符
支持数据操作
FormPath.getIn(source, 'foo[]'); // [ { bar: 1 }, { bar: 2 }, { bar: 3 } ] FormPath.getIn(source, 'foo[].bar'); // [1, 2, 3]
FormPath.setIn(source, 'foo[].bar', 0); // { foo: [{ bar: 0 }, { bar: 0 }, { bar: 0 }] }
FormPath.setIn(undefined, 'foo[].bar', 1); // { foo: [] } FormPath.setIn(undefined, 'foo[].bar', [1, 2, 3]); // { foo: [{ bar: 1 }, { bar: 2 }, { bar: 3 }] }
FormPath.setIn(undefined, '[].bar', 1); // [] FormPath.setIn(undefined, '[].bar', [1, 2, 3]); // [{ bar: 1 }, { bar: 2 }, { bar: 3 }]
FormPath.deleteIn(source, '[].bar'); // { foo: [{}, {}, {}] }