Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program API-device-clipboard


May 19, 2021 WeChat Mini Program Development Document


Table of contents


wx.setClipboardData(OBJECT)

Base library version 1.1.0 starts to support, and low versions need to be compatible

Set the contents of the system clipboard.

OBJECT parameter description:

Parameters Type Required Description
data String Is What you need to set up
success Function Whether The interface calls a successful callback function
fail Function Whether The interface calls the failed callback function
complete Function Whether Callback function at end of interface call (call succeeds, fails are executed)

Example code:

wx.setClipboardData({
  data: 'data',
  success: function(res) {
    wx.getClipboardData({
      success: function(res) {
        console.log(res.data) // data
      }
    })
  }
})

wx.getClipboardData(OBJECT)

Base library version 1.1.0 starts to support, and low versions need to be compatible

Get the contents of the system clipboard

OBJECT parameter description:

Parameters Type Required Description
success Function Whether The interface calls a successful callback function
fail Function Whether The interface calls the failed callback function
complete Function Whether Callback function at end of interface call (call succeeds, fails are executed)

Success returns a description of the parameters:

Parameters Type Description
data String The contents of the clipboard

Example code:

wx.getClipboardData({
  success: function(res){
    console.log(res.data)
  }
})