antd 處理瀏覽器自動填充密碼問題


antd在處理瀏覽器自動填充的問題時候,加input屬性autocomplete = off或者autocomplete =‘new-password’並不能解決問題

網上有一種解決方案比較靠譜:就是state加當前密碼框的屬性,點擊表單之后再去修改屬性值為password. 感覺比較復雜!

其實:一行代碼就可以解決.

<>
  <Input style={{ height: '0px', width: '0px', overflow: 'hidden', padding: '0px', border: 'none', position: 'absolute' }} maxLength={11} />
    <FormItem label="登錄密碼" {...this.formLayout}>
      {getFieldDecorator('password', {
        rules: [
          {
            required: true,
            message: '請輸入登錄密碼',
          },
        ],
        initialValue: '000000',
      })(<Input.Password password placeholder="請輸入" style={{ width: '100%' }} />)}
  </FormItem>
</>

完整用例

 isEdit是指當前是否是修改!

其實就是欺騙瀏覽器.哈哈哈哈哈!!!!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM