vue 复制内容

yarn add vue

mian.js中设置

//复制
import VueClipboard from 'vue-clipboard2'
Vue.use(VueClipboard)

控件上面使用

        复制下载地址
              
    onCopySuccess() {
      this.$message.success("复制成功")
    },
    onCopyError() {
      this.$message.error("复制失败")
    },

JavaScript中使用

this.$copyText(`地址:${this.detail.address}\n收件人: ${this.detail.name}\n电话:${this.detail.phone}`).then(
		        res => {
		          console.log(res)
		          this.$toast("已成功复制,可直接去粘贴");
		        },
		        err => {
		          this.$toast("复制失败");
		        } )

你可能感兴趣的:(#,vue,vue.js,javascript,前端)