input 判断输入
type ==int 整数 maxLength 最大位数
type ==float 数字 保留两位小数 maxStr 最大值
inputChange( $event ) {
let int = $event
if( this.type == 'int' ) {
if( this.model && this.model.length > this.maxLength ) {
this.model = this.model.slice( 0,this.maxLength );
}
$event = this.model == '' ? '' : Number( parseInt(this.model)).toString() != 'NaN' ? Number( parseInt(this.model)).toString() : '';
} else if( this.type == 'float' ) {
$event = $event.match( /^\d*(\.?\d{0,2})/g)[0]
// if( parseFloat( $event ) >= parseFloat( this.maxStr ) ) {
// $event = ( $event/10 ).toString().match( /^\d*(\.?\d{0,2})/g)[0]
//}
}
if( parseFloat( $event ) > parseFloat( this.maxStr ) ) {
$event = $event.substr(0,$event.length - 1)
//大于maxStr 阻止输入 吃掉最后一位
}
this.model = $event
}