亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

類型錯誤:無法讀取未定義 React 的屬性“匹配”

類型錯誤:無法讀取未定義 React 的屬性“匹配”

躍然一笑 2022-08-18 10:02:50
我有兩個。在寄存器中,表單函數有效,但在 createEvent 中則不然。我正在用于管理我的表單。match()react-final-form注冊:const emailReg = value => (value.match(/^[a-z\d]+[\w\d.-]*@(?:[a-z\d]+[a-z\d-]+\.){1,5}[a-z]{2,6}$/) ? undefined : `Wrong e-mail format`);...<Field            name="email"            validate={composeValidators(required, emailReg)}          >            {({ input, meta }) => (              <div className={styles.registerFormField}>                <input                  {...input}                  type="email"                  placeholder="E-mail"                  className={styles.registerFormInput}                />                {meta.error && meta.touched && (                  <span className={styles.registerError}>{meta.error}</span>                )}              </div>            )}          </Field>創建事件 :const timeReg = value => (value.match(/^(20|21|22|23|[01]d|d)(([:][0-5]d){1,2})$/) ? undefined : `Wrong time format`);...  <Field            name="timeStartEvent"            validate={composeValidators(timeReg)}          >            {({ input, meta }) => (              <div className={styles.createEventFormField}>                <label className={styles.createEventFormLabel}>                  <img                    src={TimeIcon}                    className={styles.createEventFormIcon}                  />                </label>                <input                  {...input}                  type="text"                  placeholder="Poczatek"                  className={styles.createEventFormInput}                  style={{                    width: "40%",                    marginRight: "0",                    borderRight: "1px solid #ddd",                    borderRadius: "15px 0 0 15px"                  }}                />                <Field                  name="timeEndEvent"                  validate={composeValidators(timeReg)}                >
查看完整描述

1 回答

?
aluckdog

TA貢獻1847條經驗 獲得超7個贊

您沒有將值傳遞給 ,請驗證該值timeReg


const timeReg = value =>

  // check if value exists

  value && value.match(/^(20|21|22|23|[01]d|d)(([:][0-5]d){1,2})$/)

    ? undefined

    : `Niew?a?ciwy format`;

或傳遞一個值以點贊timeReg


<Field

   name="timeStartEvent"

   validate={composeValidators(() => timeReg(value))}

 >


查看完整回答
反對 回復 2022-08-18
  • 1 回答
  • 0 關注
  • 72 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號