Skip to content

xwnwho/copy-to-clipboard

Repository files navigation

copy-to-clipboard3

配置和代码基本和copy-to-clipboard一致,解决document.execCommand('copy')引起的页面卡顿和延迟

复制后不会恢复页面原来的高亮

安装

npm i copy-to-clipboard3

使用

import copy from 'copy-to-clipboard3';
 
copy('Text');
 
// Copy with options
copy('Text', {
  debug: true,
  format: 'default'
});

⚠ 使用警告

提供的是未转译的版本:

针对 Vue CLI 3+, 需要这样:

module.exports = {
  transpileDependencies: [
    'copy-to-clipboard3',
  ]
}

针对 Vue CLI 2 需要这样:

      {
        test: /\.js$/,
        loader: 'babel-loader',
-       include: [resolve('src'), resolve('test')]
+       include: [
+         resolve('src'),
+         resolve('test'),
+         resolve('node_modules/copy-to-clipboard3'),
+       ]
      }