
你好,我有一個需要在Antd Input表單中的clear欄位上自定義一個功能。除了能夠清除該欄位之外,我還想添加一些內容,例如重新加載頁面或其他內容。
Antd中的allowClear函式可以自定義嗎?或者如果沒有,是否有適合這種情況的最佳解決方案?謝謝
uj5u.com熱心網友回復:
檢查以下示例
allowClear={{ clearIcon: <CloseOutlined onClick={ onFieldClear } />
應用程式.tsx
import React from "react";
import "antd/dist/antd.css";
import "./index.css";
import { Input } from "antd";
import { CloseOutlined } from "@ant-design/icons";
const App: React.FC = () => {
const onFieldClear = () => {
console.log("reload page or do something...");
};
return (
<>
<Input
placeholder="input with clear icon"
allowClear={{ clearIcon: <CloseOutlined onClick={ onFieldClear } /> }}
/>
</>
);
};
export default App;
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/524045.html
標籤:形式蚂蚁
