import InputNumber from '../src/index'
import '../assets/index.less'
function getSum (str) {
let total = 0
str.split('').forEach((c) => {
const num = Number(c)
if (!isNaN(num)) {
total += num
}
})
return total
}
export default {
data () {
return {
value: 1000,
}
},
render () {
return (
`$ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}
/>
`${value}%`}
parser={value => value.replace('%', '')}
/>
`${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
}
/>
In Control
{ this.value = value }}
formatter={value => `$ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}
/>
Strange Format
`$ ${value} - ${getSum(value)}`}
parser={value => (value.match(/^\$ ([\d\.]*) .*$/) || [])[1]}
/>
)
},
}