I don't know sometime people doesn't understand, what needed is buefy input which type is text, because on default it must empty string, but when input value its only accept number, this is my answer:
Input tag:
<b-input
type="text"
v-model="onlyNumber"
:placeholder="'Input only number example: 345678'"
@keypress.native="isNumber($event)"
/>
script:
data() {
return {
onlyNumber: '',
};
},
methods: {
isNumber(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
evt.preventDefault();
}
return true;
},
},
Pros : default is empty string, but only accept number
Const : accepted number will settled as string of number example : "333214234", just convert to number if you have need on number form
b-input
from? – Ritualist@input.native
event and prevent the event if it's not a number. – Ritualist