[英]Disable custom element in Polymer from being clicked
What is the best way to disable a custom-element from being clicked (eg while it is in an animation state or just because it should be disabled for the user). 禁止单击自定义元素的最佳方法是什么(例如,当它处于动画状态时或仅仅因为应该为用户禁用它)。 Meaning no input events like "click"/"tap" should be fired and links disabled.
表示不应触发任何输入事件,例如“ click” /“ tap”,并禁用链接。
I want to disable the whole element including other paper-elements, not just paper-button etc. For this I know there is the "disabled" attribute. 我想禁用包括其他纸质元素在内的整个元素,而不仅仅是纸质按钮等。为此,我知道有“ disabled”属性。
Is it best to use CSS
with pointer-events
? 最好将
CSS
与pointer-events
一起使用吗? Or is there any other way working for all browser? 还是有其他方法可用于所有浏览器?
Thanks, I am doing it now the following way, works fine: 谢谢,我现在按照以下方式进行操作,效果很好:
In custom-styles 自定义样式
:host([disabled]) {
color: #a8a8a8;
cursor: auto;
pointer-events: none;
}
In properties 在属性中
disabled: {
type: Boolean,
notify: true,
reflectToAttribute: true
}
In Code 在代码中
this.disabled = false;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.