日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網(wǎng)站首頁 編程語言 正文

使用ref手動改變antd的搜索框Input.Search的搜索內(nèi)容

作者:明月松江 更新時間: 2022-01-30 編程語言

antd提供了Input.Search搜索框組件,它的其余屬性和 Input 一致,通過value當然可以修改搜索內(nèi)容,這里介紹另外一種方法來修改搜索的內(nèi)容。
直接上代碼:

import { useRef } from 'react';
import { Input } from 'antd';
...
const searchRef = useRef(null)
...
<Input.Search
  ref={searchRef}
  placeholder='請輸入'
  onSearch={OnSearch}
  allowClear>
</Input.Search>
...
const changeVal = ()=>{
  searchRef.current.state.value = xxx
}
changeVal()
...

原文鏈接:https://blog.csdn.net/u010007013/article/details/121790527

欄目分類
最近更新