vue 一键复制文本

      handleCopy (val) {

        this.$axios

          .get('后台路径', { params: {

              mdjid: val.mdjid, jdid: val.jdid

            } })

          .then(rs => {

            if (rs) {

              this.$nextTick().then(() => {

                this.copyText(rs)

              })

            }

          })

      },

    copyText (data) {

        let url = data

        let oninput = document.createElement('input')

        oninput.value = url

        document.body.appendChild(oninput)

        oninput.select()// 选择对象

        // console.log(465464, oninput.value)

        document.execCommand('Copy')// 执行浏览器复制命令

        this.$message.success('复制成功!')

        oninput.remove()

      }

你可能感兴趣的:(vue 一键复制文本)