| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 2 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 3 年前 | ||
| 2 年前 | ||
| 3 年前 | ||
| 3 年前 | ||
| 3 年前 | ||
| 3 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 3 年前 | ||
| 2 年前 | ||
| 3 年前 | ||
| 3 年前 | ||
| 3 年前 | ||
| 2 年前 |
validator
简介
本demo是基于openHarmony系统下使用三方js库percentage-regex,percentage-regex是百分比验证的库。
下载安装
ohpm install percentage-regex
ohpm install @types/percentage-regex@3.0.0 // import percentage-regex 的时候语法报错, 其原因是percentage-regex包内不含类型声明, 需要 @types/percentage-regex 下载这个包的声明文件, 从而解决语法的报错.
- 对于OpenHarmony ohpm环境配置的详细信息,请参阅OpenHarmony环境配置指南。
使用说明
import percentageRegex from 'percentage-regex';
let result:boolean = percentageRegex({exact: true}).test("19%")
['10%'].toString() = 'foo 10% bar'.match(percentageRegex({exact: false})).toString()
接口说明
percentage-regex
| 接口 | 描述 |
|---|---|
| percentageRegex(options) | 返回匹配百分比值的正则表达式。 |
| options.exact | 类型:boolean ,默认值:false(匹配字符串中的任何百分比) ,只匹配一个精确的字符串。与“RegExp#test”一起检查某个字符串是否为百分比很有用。 |
约束与限制
在下述版本验证通过:
DevEco Studio: NEXT Beta1-5.0.3.806, SDK: API12 Release(5.0.0.66) DevEco Studio: 3.1 Beta2(3.1.0.400), SDK: API9 Release(3.2.11.9) DevEco Studio: 4.0Canary1(4.0.0.112), SDK: API10(4.0.7.2) DevEco Studio: 4.0(4.0.3.512),SDK: API10(4.0.10.9)
贡献代码
使用过程中发现任何问题都可以提Issue 给我们,当然,我们也非常欢迎你给我们提PR。
开源协议
本项目遵循 MIT License。