| 139 | }, |
| 140 | |
| 141 | format(value: string) { |
| 142 | // filter illegal characters and format integer |
| 143 | const safeValue = this.filter(value); |
| 144 | |
| 145 | // format range |
| 146 | const rangeValue = Math.max( |
| 147 | Math.min(this.data.max, +safeValue), |
| 148 | this.data.min |
| 149 | ); |
| 150 | |
| 151 | // format decimal |
| 152 | const newValue = isDef(this.data.decimalLength) |
| 153 | ? rangeValue.toFixed(this.data.decimalLength) |
| 154 | : String(rangeValue); |
| 155 | |
| 156 | return { value, newValue }; |
| 157 | }, |
| 158 | |
| 159 | onInput(event: WechatMiniprogram.Input) { |
| 160 | const { value = '' } = event.detail || {}; |