第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

重置通知狀態(tài)時,Material UI 自動完成組件不會清除輸入

重置通知狀態(tài)時,Material UI 自動完成組件不會清除輸入

慕村225694 2023-07-06 14:51:43
我正在使用 Material UI 版本 4(最新)和Informed 表單庫。我有一個自定義組件(自定義與 Informed 集成),它包裝了我使用自動完成組件渲染的 Material UI TextField。應(yīng)用程序組件? ?<Form getApi={(api) => setFormApi(api)}>? ? ? {formApi && (? ? ? ? <>? ? ? ? ? <label>? ? ? ? ? ? First name:? ? ? ? ? ? <Autocomplete? ? ? ? ? ? ? freeSolo? ? ? ? ? ? ? options={autoOptions}? ? ? ? ? ? ? renderInput={(params) => (? ? ? ? ? ? ? ? <CustomTextField field="name" {...params} />? ? ? ? ? ? ? )}? ? ? ? ? ? />? ? ? ? ? </label>? ? ? ? ? <button type="submit">Submit</button>? ? ? ? ? <button type="button" onClick={() => formApi.reset()}>? ? ? ? ? ? Reset? ? ? ? ? </button>? ? ? ? ? <FormState />? ? ? ? </>? ? ? )}? ? </Form>問題單擊重置按鈕后,您可以看到 Informed&ldquo;表單狀態(tài)&rdquo;被清除,但輸入仍然有值。關(guān)于如何解決這個問題有什么想法嗎?示例 - Codesandbox
查看完整描述

1 回答

?
慕的地8271018

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超4個贊

它們inputProps被Autocomplete組件提供的覆蓋,更改您傳遞道具的順序...rest并將其包含在具有正確值的...rest.inputProps自定義中inputProps


      <TextField

        {...rest} // should go first to allow overriding

        // only add value props for select fields

        // value={value}

        onChange={(event) => {

          setValue(event.target.value);

          if (onChange) {

            onChange(event);

          }

        }}

        onBlur={(event) => {

          setTouched(true);

          if (onBlur) {

            onBlur(event);

          }

        }}

        error={!!error}

        helperText={error ? error : helperText ? helperText : false}

        variant="outlined"

        margin="none"

        fullWidth

        inputProps={{

          ...rest.inputProps, // must include otherwise it breaks

          value:

            !select && !maskedValue && maskedValue !== 0 ? "" : maskedValue,

          maxLength: maxLength || undefined

        }}

        // eslint-disable-next-line

        InputProps={{

          style: sensitive && {

            color: "rgba(0,0,0,0)",

            caretColor: "#000"

          },

          startAdornment

        }}

        InputLabelProps={{

          shrink: true

        }}

        autoComplete="off"

        disabled={disabled}

      />


查看完整回答
反對 回復(fù) 2023-07-06
  • 1 回答
  • 0 關(guān)注
  • 165 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號