实现复制功能

2020-11-16  本文已影响0人  有一个程序媛

html代码:

<el-input  id="copy" style="width: 400px;" readonly  v- model="linkUrl">       

         <template slot="append">         

                 <span class="pointer" @click="copyAdress">复制</span>     

         </template>      

</el-input>

js代码:要写select(),不然复制不了

copyAdress() {

      var copy = document.getElementById('copy')

      copy.select()

      document.execCommand('copy')

      this.$message.success(this.$t('message.copyMsg'))

}

上一篇 下一篇

猜你喜欢

热点阅读