输入框
This commit is contained in:
@ -21,6 +21,7 @@ class eventBinding {
|
||||
let Event = []
|
||||
let isEvent = false
|
||||
let removeName = []
|
||||
let blurEvent = () => { }
|
||||
if (!elements[i] || !elements[i].attributes) {
|
||||
continue
|
||||
}
|
||||
@ -36,7 +37,8 @@ class eventBinding {
|
||||
Event.push((e) => {
|
||||
let value = e.target.value
|
||||
if (e.target.type == 'number') {
|
||||
if (e.data != '.' && (e.data != '-' || e.target.value)) {
|
||||
let str = e.target.value + ''
|
||||
if (e.data != '.' && (e.data != '-' || e.target.value) && !(str.charAt(str.length - 1) == '0' && e.target.value.toString().includes('.')) && e.target.value != '0') {
|
||||
value = Number(value)
|
||||
if((e.target.max) && value>Number(e.target.max)) {
|
||||
value = Number(e.target.max)
|
||||
@ -57,6 +59,22 @@ class eventBinding {
|
||||
that[m.value] = value
|
||||
}
|
||||
})
|
||||
blurEvent = (e) => {
|
||||
let value = e.target.value
|
||||
if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) {
|
||||
value = Number(value)
|
||||
if ((e.target.max) && value > Number(e.target.max)) {
|
||||
value = Number(e.target.max)
|
||||
}
|
||||
if ((e.target.min) && value < Number(e.target.min)) {
|
||||
value = Number(e.target.min)
|
||||
}
|
||||
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
|
||||
value = Number(e.target.dataset.min)
|
||||
}
|
||||
}
|
||||
that[m.value] = value
|
||||
}
|
||||
if(elements[i].nodeName=='IMG') {
|
||||
elements[i].src = that[m.value]
|
||||
}
|
||||
@ -114,6 +132,7 @@ class eventBinding {
|
||||
Event[t](e)
|
||||
}
|
||||
});
|
||||
elements[i].addEventListener('blur', blurEvent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user