[英]How to disable copy paste events in React antd?
I am using Ant Design Forms in my React applpication.我在我的 React 应用程序中使用 Ant Design Forms。 I would like to know how do I prevent user from copying and pasting the values in that input field.
我想知道如何防止用户复制和粘贴该输入字段中的值。
import { Input } from "antd";
<Input onPaste={(e)=>{
e.preventDefault()
return false;
}} onCopy={(e)=>{
e.preventDefault()
return false;
}} placeholder="Basic usage" />
You can also use this on a normal input in React:你也可以在 React 的普通输入上使用它:
<input
type="text"
onPaste={(e: any) => {
e.preventDefault();
return false;
}}
onCopy={(e: any) => {
e.preventDefault();
return false;
}}
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.