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

removeWidget

removeWidget là api dùng để xoá một widget đang hoạt động.

Lưu ý

Widget cũng sẽ tự động bị xoá khi hết duration. Khi đó, event onWidgetRemove sẽ được gửi về cho Mini App.

Tham số

Thuộc tínhKiểu dữ liệuBắt buộcMô tả
widgetIdstringID của widget cần xoá (nhận từ createWidget)
successFunctionCallback khi xoá widget thành công
failFunctionCallback khi xoá widget thất bại
completeFunctionCallback sau khi thực hiện bất kể thành công hay thất bại

Ví dụ

import apis from '@v-miniapp/apis'

apis.removeWidget({
widgetId: 'abc-123',
success: () => {
console.log('Widget removed')
},
fail: res => {
apis.alert({
title: 'Xoá widget thất bại',
error: {
code: res?.code,
message: res?.message,
},
})
},
})