cleaner inputs for Wealth

This commit is contained in:
2019-06-14 14:31:46 +02:00
parent 109a01a368
commit 0e71776f4f
2 changed files with 44 additions and 19 deletions

View File

@@ -0,0 +1,28 @@
<template>
<input type="text"
class="input"
:class="{'is-danger': has_error}"
:value="value"
@input="checkError"
></input>
</template>
<script>
export default {
props: ["value"],
data () {
return { has_error: false};
},
methods: {
checkError (ev) {
const newValue = ev.target.value;
this.has_error = isNaN(newValue);
this.$emit(
'input',
// Do the conversion if valid
this.has_error ? newValue : Number(newValue)
);
}
},
}
</script>