doc: 过滤器bytes支持传参step (#5760)

Co-authored-by: duqingyu <duqingyu@zj.tech>
This commit is contained in:
杜庆愉 2022-12-01 10:20:28 +08:00 committed by GitHub
parent e61194ea7a
commit 7202da8cec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 0 deletions

View File

@ -1306,6 +1306,43 @@ ${xxx | bytes}
}
```
##### 指定换算间隔参数
```
${xxx | bytes[:step]}
```
```schema
{
"type": "page",
"data": {
"bytes1": 2333,
"bytes2": 2333333,
"bytes3": 2333333333
},
"body": [
{
"type": "tpl",
"tpl": "bytes1 is ${bytes1|bytes:1024}"
},
{
"type": "divider"
},
{
"type": "tpl",
"tpl": "bytes2 is ${bytes2|bytes:1024}"
},
{
"type": "divider"
},
{
"type": "tpl",
"tpl": "bytes3 is ${bytes3|bytes:1024}"
}
]
}
```
### asArray
将数据包成数组

View File

@ -132,6 +132,15 @@ test(`filter:bytes`, () => {
})
).toBe('234 KB');
});
test(`filter:bytes:step`, () => {
expect(
resolveVariableAndFilter('${a|bytes:1024}', {
a: 234343
})
).toBe('229 KB');
});
test(`filter:round`, () => {
expect(
resolveVariableAndFilter('${a|round}', {