MCPcopy
hub / github.com/youzan/vant-weapp / format

Function format

packages/stepper/index.ts:141–157  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

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 || {};

Callers

nothing calls this directly

Calls 1

isDefFunction · 0.90

Tested by

no test coverage detected