AI营销辅助 普强使用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

addUnit.js 374 B

2 years ago
12345678
  1. import validation from './test.js';
  2. // 添加单位,如果有rpx,%,px等单位结尾或者值为auto,直接返回,否则加上rpx单位结尾
  3. export default function addUnit(value = 'auto', unit = 'rpx') {
  4. value = String(value);
  5. // 用uView内置验证规则中的number判断是否为数值
  6. return validation.number(value) ? `${value}${unit}` : value;
  7. }