复制按钮调用copyMes,handleText处理复制出去的信息格式

//处理待复制文本
  handleText = (item) => {
    let bankOfDeposit = "",
      bankAccount = "",
      companyAddress = "",
      companyTelephone = "",
      taxNumber = "",
      titleName = "";
    if (item) {
      titleName = item?.titleName;
      taxNumber = item?.taxNumber;
      companyAddress = item?.companyAddress;
      companyTelephone = item?.companyTelephone;
      bankOfDeposit = item?.bankOfDeposit;
      bankAccount = item?.bankAccount;
    }

    let results =
      "名称:" +
      titleName +
      `\n` +
      "纳税人识别号:" +
      taxNumber +
      `\n` +
      "地址:" +
      companyAddress +
      `\n` +
      "电话:" +
      companyTelephone +
      `\n` +
      "开户行:" +
      bankOfDeposit +
      `\n` +
      "账号:" +
      bankAccount;

    return results;
  };
  copyMes = () => {
    const { invoiceTemplates } = this.props;
    Taro.setClipboardData({
      data: this.handleText(invoiceTemplates),
      success: function () {
        Taro.getClipboardData({
          success: () => {
            Taro.showToast({
              title: "复制成功",
            });
          },
        });
      },
    });
  };

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐