Chuyển tới nội dung chính

getClipboard

getClipboard là API dùng để lấy nội dung từ clipboard của thiết bị.

Tham số

Thuộc tínhKiểu dữ liệuMô tả
successFunctionCallback function khi lấy dữ liệu từ clipboard thành công.
failFunctionCallback function khi lấy dữ liệu từ clipboard bất thành.
completeFunctionCallback function khi việc lấy dữ liệu từ clipboard hoàn tất bất kể thành công hay thất bại.

Callback function payload

Thuộc tínhKiểu dữ liệuMô tả
textstringNội dung của clipboard.

Ví dụ

import apis from '@v-miniapp/apis'

function setClipboard() {
apis.setClipboard({
text: this.data.text,
success: (res) => {
apis.alert({ title: "Success" });
},
fail: (e) => {
apis.alert({ title: "error", content: JSON.stringify(e) });
},
});
}

function onGetClipboard() {
apis.getClipboard({
success: (res) => {
apis.alert({ title: "Success", content: res.text });
},
fail: (e) => {
apis.alert({ title: "error", content: JSON.stringify(e) });
},
});
}