Apiccloud can copy text with one key on mobile terminal, compatible with IOS and Android

Time:2020-11-29

UsedclipBoardmodular
You can copy and paste directly

`
html :

<div>
    <input style="border:none;" type="text" readonly="" id="copy_text" value="123456">
    < span @ Click = "copynum1()" > click Copy</span>
  </div>

js

copyNum1 () {
      //Text is the text to be copied
      var text = document.getElementById("copy_text").value;
      var clipBoard = api.require('clipBoard');
      clipBoard.set({
        value: text
      }, function (ret, err) {
        console.log(ret);
        if (ret) {
          Alert (copy succeeded)
        } else {
          Alert ("copy failed, please try again");
        }
      });

`
Finally, thanks to the original blogger: https://blog.csdn.net/l425059…