dongtingyue
V2EX  ›  问与答

vee-validate 正则验证通过但是最终结果为 false

  •  
  •   dongtingyue · Feb 3, 2023 · 1002 views
    This topic created in 1228 days ago, the information mentioned may be changed or developed.
    <input type="text"
                v-model="test2"
                id="test2"
                name="test2"
                v-validate="'remoteString'"
    />
    <span class="form-error"
    v-if="errors.has('test2')">
    {{errors.first('test2')}}
    </span>
    <button @click="test">测试</button>
    
    
     async test () {
     this.$validator.errors.clear()
     this.$validator.validateAll().then((result) => {
     console.log(result) //falase
     console.log(this.$validator) 
     })
     },
     
     
      Validator.extend('remoteString', {
            validate: (value, obj) => {
                const reg = new RegExp('\\d+', 'ig')
                return reg.test(value)
            }
        })
    
    ```
    默认的 require 规则正常,有可能是什么问题? v2 的
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3247 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 55ms · UTC 12:38 · PVG 20:38 · LAX 05:38 · JFK 08:38
    ♥ Do have faith in what you're doing.