<a-input v-model="inputValue" @input="validateInput"></a-input>
export default {
data() {
return {
inputValue: ''
};
},
methods: {
validateInput() {
this.inputValue = this.inputValue.replace(/[^\d]/g, '');
}
}
}
请注意,在这个例子中,我们没有阻止用户粘贴包含小数点的文本。如果需要更严格的限制,请考虑使用其他方法。