Vue.js judges how to use regular expressions for input input

for example, the following code:

< input type= "text" v muri model = "sellPrice" >
< input type= "text" v muri model = "buyVolume" >

reg:/ ^ [0-9] + (. [0-9] {1 Magazine 8})? $/
reg1:/ [0-9] dudes /

watch: {

    buyPrice:function(){
       
    },
    sellPrice:function(){
        let a = this.sellPrice;
        this.sellPrice = a.match(this.reg,"");
    },
    buyVolume:function(){
        this.buyVolume = this.buyVolume.match(/[0-9]\d*/,"");
       
    },
    sellVolume:function(){
        this.sellVolume = this.sellVolume.match(/[0-9]\d*/,"");
    }
}

Price could not succeed.
Why does sellVolume succeed but report this.sellVolume.match is not a function

Apr.11,2021

I usually write to encapsulate the regular expression into a method, and then verify the input data when I enter the data. For example, I recently worked on a project to format the input bank card number.

//
export function isBankNumber(str) {
    const reg = /^([1-9]{1})(\d{15}|\d{18})$/
    return reg.test(str)
}
//input
if (!isBankNumber(vm.temp.bankAccount.replace(/\s+/g,""))) {
                vm.showToast = true;
                vm.toastTitle = "';
                vm.toastType = "text';
                vm.toastWidth = '200px';
                return;
  }

Why do you want to write it in watch? you can write it in computed, or you can write a filter.


match gets an array, so the error and regularity should be / ^ [0-9] d $| (^ [0-9] +. [0-9] {0jue 8}) /, watch test data is fine. On the contrary, it will be troublesome to use computed


multiple modes
watch

computed: {
    value: {
        set() {
        },
        get() {
        }
     }
     }
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38550-2c11b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38550-2c11b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?