1.首先要安装clipboard-polyfill
2.引入clipboard-polyfill
import clipboard from 'clipboard-polyfill'
3.创建一个点击事件
<div class="copy" @click="copy">复制文本</div>
4.点击事件
copy () {
clipboard.writeText(this.text)
Toast({
iconClass: 'icon icon-success',
message: '复制成功',
duration: 500
})
}