Skip to content

Commit

Permalink
修复type=number时step为小数的精度问题
Browse files Browse the repository at this point in the history
  • Loading branch information
严文彬 authored and 严文彬 committed Jun 1, 2020
1 parent aae5030 commit 1810b30
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions components/xy-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,26 +319,22 @@ export default class XyInput extends HTMLElement {
}
if(this.btnAdd){
this.btnAdd.addEventListener('click',()=>{
if(this.value-this.max<0){
this.value = Number(this.value)+Number(this.step);
this.dispatchEvent(new CustomEvent('change',{
detail:{
value:this.value
}
}));
}
this.input.stepUp();
this.dispatchEvent(new CustomEvent('change',{
detail:{
value:this.value
}
}));
})
}
if(this.btnSub){
this.btnSub.addEventListener('click',()=>{
if(this.value-this.min>0){
this.value = Number(this.value)-Number(this.step);
this.dispatchEvent(new CustomEvent('change',{
detail:{
value:this.value
}
}));
}
this.input.stepDown();
this.dispatchEvent(new CustomEvent('change',{
detail:{
value:this.value
}
}));
})
}
this.pattern = this.pattern;
Expand Down

0 comments on commit 1810b30

Please sign in to comment.