問題描述:table內增加了搜索框第一次輸入內容,等下次打開的時候搜索框內內容未清空,仍然存在,
原因:未重現加載table 即selectkeys未清空
解決:
clearFilters參數antd自帶的清空輸入框內容的方法,定義一個全局的方法把clearFilters賦值給這個方法clearTabSearch,再彈窗取消和確定按鈕點擊的時候調用
filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => ( <div style={{ padding: 8 }}> <Input ref={node => { this.searchInput = node; }} placeholder={`Search ${dataIndex}`} value={selectedKeys[0]} onChange={e => setSelectedKeys(e.target.value ? [e.target.value] : [])} onPressEnter={() => this.handleSearch(selectedKeys, confirm, dataIndex)} style={{ width: 188, marginBottom: 8, display: 'block' }} /> <Button type="primary" onClick={() => this.handleSearch(selectedKeys, confirm, dataIndex)} icon="search" size="small" style={{ width: 90, marginRight: 8 }} > Search </Button> <Button onClick={() => this.handleReset(clearFilters)} size="small" style={{ width: 90 }}> Reset </Button> </div> ),