vue实现页面内容禁止选中功能,仅输入框和文本域

今天小编就为大家分享一篇vue实现页面内容禁止选中功能,仅输入框和文本域可选,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

上网上翻了翻,共找到两种方式

CSS样式控制,只需将下面代码复制到 vue应用下,index.html文件中的body标签上

*{ -webkit-touch-callout:none; /*系统默认菜单被禁用*/ -webkit-user-select:none; /*webkit浏览器*/ -khtml-user-select:none; /*早期浏览器*/ -moz-user-select:none;/*火狐*/ -ms-user-select:none; /*IE10*/ user-select:none; } input{ -webkit-user-select:auto; /*webkit浏览器*/ } textarea{ -webkit-user-select:auto; /*webkit浏览器*/ }

js控制方式,需要重写onselectstart(),onselect。(将下面代码复制到body标签上即可,注意此种写法输入框和文本域也不可选)

onselectstart='return false' onselect='return false' oncontextmenu='return false' #此句禁用鼠标右键

以上这篇vue实现页面内容禁止选中功能,仅输入框和文本域可选就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/a8e13fa4670f0a13c0e5ec190d17e59c.html