首页 > 解决方案 > 禁用 html 样式的复制

问题描述

header.value是否可以在此“如果”中禁用副本?(如果是,如何?)

<div
    class="value"
    style="{{header.name === 'abc' ? 'color: transparent; text-shadow: 0 0 5px black;' : ''}}"
>
    {{ header.value }}
</div>

谢谢!

标签: javascripthtmlcss

解决方案


您可以在 css 中使用它:

.value {
   -moz-user-select: none;  
   -webkit-user-select: none;  
   -ms-user-select: none;  
   -o-user-select: none;  
   user-select: none;
}

这将阻止用户选择文本并复制它。示例:https ://codesandbox.io/s/small-sea-rseff?file=/index.html


推荐阅读