Use the vant ui component library of the likes team < van-field >

use the vant ui component library of the likes team, and use < van-field > in the form, but it seems that the official parameter "error-message" can only be a fixed string and cannot be changed dynamically. Is there any other method or effectiveness that needs to be written by yourself? the official does not have a corresponding method

.
Jul.15,2021

The official example of

is to put a string directly, but you can v-bind it to a variable, and the text of the variable change prompt changes.

<van-field
    v-model="phone"
    label=""
    placeholder=""
    :error-message="errorMessage"
  />

and the form validation is really not built-in, which is very speechless. It is recommended that you combine async-validator to join one, and it is not difficult

.

error-message can bind a string variable, remember to add a colon (: error-message= "yourText")
for example, enter an account and enter a password:

<van-row class="register-name">
          <van-field
            v-model="username"
            clearable
            label=""
            icon="question"
            placeholder="/"
            :error-message="errorMessage.userInput"
          />
      </van-row>
      <van-row class="register-password">
        <van-field
          v-model="password"
          type="password"
          label=""
          placeholder=""
          :error-message="errorMessage.pwdInput"
        />
      </van-row>

definition errorMessage: in data

errorMessage: { userInput:"", pwdInput:"", zipCode:"" },

Ps: I store all the information that needs a red prompt in an errorMessage object, which is convenient to change and add code.
is easy to use!
this.errorMessage.pwdInput = "password error" page response displays the prompt;
if you want to turn off the prompt, it's even easier.
Direct this.errorMessage.pwdInput = " assignment is empty.

for final verification, if I write too much, I will sum up a set of general regular sum verification methods, and encapsulate it by myself. Every time I use it, I will directly import . How happy I am! 2333


can your v-model be used?


van-card build has no way to v-for? Use the direct error report?


< van-field VMI model = "mobile" name= "mobile" placeholder= "Mobile": rules= "[{required: true, message: 'Please fill in Mobile phone'}, {pattern, message: 'Mobile number is not in the correct format'}]" / >

data: {pattern: / ^ 1d {10} /}

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-1b3758a-2c0a2.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-1b3758a-2c0a2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?