安装组件,输入以下命令
npm install --save vue-clipboard2
main.js 引入以下代码
import VueClipboard from 'vue-clipboard2'
Vue.use(VueClipboard)
html
<span @click="copyInfo">复制</span>
使用方法,在复制方法中写以下内容
copyInfo(){
let that = this
this.$copyText(this.detailInfo.cpContent).then(function (e) {
if(e != undefined){
that.$message.success('复制成功')
}
})
}
//this.detailInfo.cpContent 要复制的文本内容