-
Notifications
You must be signed in to change notification settings - Fork 771
FormatValue
Shawn Xu edited this page Jun 3, 2018
·
1 revision
- Import
- formatValueByGapRule(gapRule: string, value: string, gap: string, range, isAdd)
- formatValueByGapStep(step: number, value: string, gap: string, direction: string, range, isAdd, oldValue)
- trimValue(value: string, gap: string)
import { xxx } from '../_util/formate-value'
按照指定规则给字符串加"空隙"
// gapRule "空隙"规则
// value 待处理字符串
// gap "空隙"默认为空格,可为`,`等其他字符
// range, isAdd用于input 其他情况可忽略
var res = formatValueByGapRule('3|4|4', '13311112222')
console.log(res.value) // 133 1111 2222
formatValueByGapStep(step: number, value: string, gap: string, direction: string, range, isAdd, oldValue)
按照指定间隔给字符串加"空隙"
// step 间隔
// value 待处理字符串
// direction left(1,222,333)/right(111,222,3)
// gap "空隙"默认为空格,可为`,`等其他字符
// range, isAdd, oldValue用于input 其他情况可忽略
var res0 = formatValueByGapStep(3, '11122233', 'left')
var res1 = formatValueByGapStep(3, '11122233', 'right', ',')
console.log(res0.value) // 111 222 33
console.log(res1.value) // 11,122,233
清除字符串"空隙"
// value 待处理字符串
// gap "空隙"默认为空格,可为`,`等其他字符
trimValue('1 2 3') // 123
trimValue(',1,2,3', ',') // 123
Welcome to the Mand Mobile wiki, please check our homepage
Copyright © 2012-2018 Didi Chuxing. All Rights Reserved