阅读(3014) (8)

支付宝小程序API 剪贴板

2017-11-27 20:00:20 更新

my.getClipboard

获取剪贴板数据。

入参

名称 类型 必填 描述
success Function 调用成功的回调函数
fail Function 调用失败的回调函数
complete Function 调用结束的回调函数(调用成功、失败都会执行)

success 返回值

名称 类型 描述
text String 剪贴板数据

代码示例

Page({
  data: {
    text: '3.1415926',
    copy: '',
  },

  
  handlePaste() {
    my.getClipboard({
      success: ({ text }) => {
        this.setData({ copy: text });
      },
    });
  },
});

my.setClipboard

设置剪贴板数据。

入参

名称 类型 必填 描述
text String 剪贴板数据
success Function 调用成功的回调函数
fail Function 调用失败的回调函数
complete Function 调用结束的回调函数(调用成功、失败都会执行)

代码示例

Page({
  data: {
    text: '3.1415926',
    copy: '',
  },


  handleCopy() {
    my.setClipboard({
      text: this.data.text,
    });
  },
});