[英]React MUI Chip onDelete access to stopPropagation method
I have a Chip like:我有一个像这样的芯片:
const onDelete = (e) => {
e.stopPropagation();
// e.nativeEvent.stopPropagation();
};
return (
<Chip
label={name}
sx={sx}
component={NavLink}
to={to}
clickable={true}
onDelete={onDelete}
/>);
None of the calls stopPropagation()
worked, because they are undefined on the Event sent by MUI to the onDelete
callback.没有一个调用
stopPropagation()
起作用,因为它们在MUI发送到onDelete
回调的事件中未定义。
Is there anyway I can prevent this chip to follow the Link in to
attribute if user clicked to Delete?如果用户单击删除,我是否可以阻止该芯片跟随链接
to
属性?
The stopPropagation()
prevents further propagation of the current event but redirecting to links are still processed. stopPropagation()
阻止当前事件的进一步传播,但仍会处理重定向到链接。 If you want to stop those behaviors, you can use preventDefault()
method :如果你想停止这些行为,你可以使用
preventDefault()
方法:
const onDelete = (e) => {
e.preventDefault();
// e.nativeEvent.stopPropagation();
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.