在input中如何禁止復(fù)制、粘貼、鼠標(biāo)右鍵彈出面板選項
主要事件
-
右鍵彈出面板選項
oncontextmenu -
復(fù)制
oncopy -
粘貼
onpaste
原生input實現(xiàn)
- 禁止復(fù)制
<input oncopy="return false" />
- 禁止粘貼
<input onpaste="return false" />
- 禁止鼠標(biāo)右鍵彈出面板選項
<input oncontextmenu="return false" />
React中實現(xiàn)
- 禁止復(fù)制
<input onCopy={(e) => e.preventDefault()} />
- 禁止粘貼
<input onPaste={(e) => e.preventDefault()} />
- 禁止鼠標(biāo)右鍵彈出面板選項
<input onContextMenu={(e) => e.preventDefault()} />

浙公網(wǎng)安備 33010602011771號