Svelte防止用户在MAPBOX上输入
当cssdisableUserInput
是true
时,我正在尝试阻止用户输入。
因此,基本上,在我的主标签中,我拥有这样的:
<div id=userinput disabled={cssDisableUserinput}>
<div id="map">
</div>
在我的CSS中,我有:
<style>
#map {
width: 1300px;
height: 800px;
}
#userinput{
width: 1300px;
height: 800px;
pointer-events: none;
}
</style>
但是,即使cssdisableuserinput
是false
,它也完全阻止用户输入。
阻止用户输入的更好方法是什么?
I am attempting to block user input when cssDisableUserInput
is true
.
So basically within my main tags I have this:
<div id=userinput disabled={cssDisableUserinput}>
<div id="map">
</div>
within my CSS I have:
<style>
#map {
width: 1300px;
height: 800px;
}
#userinput{
width: 1300px;
height: 800px;
pointer-events: none;
}
</style>
And yet it completely blocks user input even when cssDisableUserinput
is false
.
What is a better approach to blocking user input?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
防止交互的事物是
指针事件:无;
,而不是disabled
。您不能禁用div
。您可能需要将该属性提取到单独的类中,并使用cssdisableuserinput
flag有条件地应用该属性。(我不知道Mapbox API,也许有一种内置机制更适合实现这一目标。上面的方法仍然可以通过键盘进行交互。)
The thing that prevents interaction is
pointer-events: none;
, notdisabled
. You cannot disable adiv
. You might want to extract that property into a separate class and apply that conditionally using yourcssDisableUserinput
flag.(I do not know the Mapbox API, maybe there is a built-in mechanism that would be better suited for achieving this. The above approach may still allow interaction via the keyboard.)