Home >Web Front-end >Vue.js >How vue.js determines whether the input is a number
vue.js method to determine whether the input is a number: first create a front-end sample file; then use the regular expression "var numReg=/^[0-9]*$/" in vue to determine the input Whether the value is a number is sufficient.
The operating environment of this tutorial: windows7 system, vue version 2.0. This method is suitable for all brands of computers.
Related recommendations: "vue.js Tutorial"
Regular expressions can be used in vue to determine whether the input value is a number:
var numReg = /^[0-9]*$/ var numRe = new RegExp(numReg) if (!numRe.test(number)) { this.$message({ type: 'warning', message: '请输入数字 ', duration: 10000, showClose: true, }) return false }
Regular expression /^[0-9]*$/ means that only numbers can be entered:
^: represents the beginning of the regular expression,
$ represents the regular expression End,
* represents matching 0--infinite,
[] represents the relationship of or
The above is the detailed content of How vue.js determines whether the input is a number. For more information, please follow other related articles on the PHP Chinese website!