getClipboard
getClipboard là API dùng để lấy nội dung từ clipboard của thiết bị.
Tham số
| Thuộc tính | Kiểu dữ liệu | Mô tả |
|---|---|---|
| success | Function | Callback function khi lấy dữ liệu từ clipboard thành công. |
| fail | Function | Callback function khi lấy dữ liệu từ clipboard bất thành. |
| complete | Function | Callback 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ính | Kiểu dữ liệu | Mô tả |
|---|---|---|
| text | string | Nộ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) });
},
});
}