移动端复制文字到复制板上

342 阅读1分钟
<!--h5-->
 <li>
        <div class="flex">
          <span>订单号</span>
          <em id="copyFromThis">{{ shopOrder.orderNo }}</em>
        </div>
        <button @click="copyThat()">复制</button>
 </li>
 // script 方法
 
   copyThat() {
      let text = document.getElementById('copyFromThis');
      window.getSelection().selectAllChildren(text);
      document.execCommand("Copy");
    }
 

不用input的,整太复杂了