配置和代码基本和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'),
+ ]
}