fastmock技术社区
首页 更多应用
1 修改iview的标签为i-的形式而不是驼峰的形式 3,092 阅读 2 PHP微信和企业微信签名 2,830 阅读 3 在VUE中怎么全局引入sass文件 2,473 阅读 4 解决Macos下storm系列IDE卡顿的问题 2,153 阅读 5 vscode硬件占用较高解决方案 2,142 阅读
默认分类 JS VUE CSS mac使用技巧 React fastmock
登录 / 注册
标签搜索
  • react
  • js
  • vue
  • vscode
  • nodejs
  • 项目
  • 代码
  • webpack
  • 工具
  • nginx
  • 小程序
  • css
  • fastmock
  • eslint
  • npm
  • http
  • vue-cli3
  • git
  • 浏览器
  • const
侧边栏壁纸
博主昵称
fastmock技术社区

  • 累计撰写 104 篇文章
  • 累计收到 26 条评论
  • 首页
  • 栏目
    • 默认分类
    • JS
    • VUE
    • CSS
    • mac使用技巧
    • React
    • fastmock
  • 页面
    • 更多应用
搜索到 1 篇与 的结果
  • js复制和粘贴内容 2022-03-19
    js复制和粘贴内容 复制-将指定内容添加到粘贴板/** * copyToClip * @param content * @param callback */ export const copyToClip = (content: string, callback?: () => void) => { var aux = document?.createElement?.('input'); aux?.setAttribute?.('value', content); document?.body?.appendChild?.(aux); aux?.select(); document?.execCommand('copy'); document?.body?.removeChild?.(aux); return callback?.(); };粘贴 js不能直接读取粘贴板内容,下面的代码在多数环境下不生效const text = await navigator?.clipboard?.readText?.();我们采取变通的方案来处理。1、在页面中添加一个input输入框,将其绝对定位到页面中不可见的位置<input type='text' id='text-all' key='text-all' onPaste={(e) => handlePaste(e)} style={{ position: 'absolute', top: -10000, zIndex: 10000 }} />监听到ctrl-v事件时,先让上面的input获得焦点,再手动触发他的paste事件,这时input会填充粘贴板中的内容const hideInput: HTMLInputElement = document.getElementById('text-all') as any; hideInput?.focus(); hideInput?.dispatchEvent(new Event('paste', { bubbles: true }));给这个input添加onPaste事件,在事件处理函数中获取input的内容,或者获取粘贴板的内容const clipboardData = e?.clipboardData || e.originalEvent?.clipboardData;
    • 2022年03月19日
    • 606 阅读
    • 0 评论
    • 0 点赞
博主栏壁纸
博主头像 fastmock技术社区

104 文章数
26 评论量
  • Mac电脑下查看某文件或者目下下的文件的代码行数工具(cloc)
  • linux常用指令备忘
  • 推荐一个js常用工具函数库
热门文章
  1. 1 修改iview的标签为i-的形式而不是驼峰的形式
    修改iview的标签为i-的形式而不是驼峰的形式
    3092 阅读 - 12/20
  2. 2 PHP微信和企业微信签名
    PHP微信和企业微信签名
    2830 阅读 - 04/19
  3. 3 在VUE中怎么全局引入sass文件
    在VUE中怎么全局引入sass文件
    2473 阅读 - 01/10
最新回复
  • zhjylgtbqr
    zhjylgtbqr
    2024-10-19
    兄弟写的非常好 https://www.cscnn.com/
  • fowjqliahm
    fowjqliahm
    2024-10-19
    文章的确不错啊https://www.cscnn.com/
  • mwllgngafn
    mwllgngafn
    2024-10-19
    文章的确不错啊https://www.cscnn.com/
  • wpkzznhnnu
    wpkzznhnnu
    2024-10-06
    想想你的文章写的特别好www.jiwenlaw.com
  • fcsrtvwitk
    fcsrtvwitk
    2024-10-06
    想想你的文章写的特别好www.jiwenlaw.com
今日天气
2019 - 2023 © Reach - fastmock blog
已运行 00 天 00 时 00 分 00 秒
fastmock blog fastmock