如何仅让vue中的输入框和文本域可选中,页面其他内容禁止选中?

更新于
2026-10-01 21:52:11
0阅读来源:SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计263个文字,预计阅读时间需要2分钟。

如何仅让vue中的输入框和文本域可选中,页面其他内容禁止选中?

网上翻看了翻,总结到两种方式控制CSS样式:将下面代码复制到Vue应用下的index.文件的body标签上:

如何仅让vue中的输入框和文本域可选中,页面其他内容禁止选中?

css* { -webkit-touch-callout:none; /!* 系统默认菜单被禁用 *! -webkit-user-select:none; /!* webkit浏览器禁用选择文本 *!}

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

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。

阅读全文

本文共计263个文字,预计阅读时间需要2分钟。

如何仅让vue中的输入框和文本域可选中,页面其他内容禁止选中?

网上翻看了翻,总结到两种方式控制CSS样式:将下面代码复制到Vue应用下的index.文件的body标签上:

如何仅让vue中的输入框和文本域可选中,页面其他内容禁止选中?

css* { -webkit-touch-callout:none; /!* 系统默认菜单被禁用 *! -webkit-user-select:none; /!* webkit浏览器禁用选择文本 *!}

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

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。

阅读全文