my.onUnhandledRejection
onUnhandledRejection
Giới thiệu
my.onUnhandledRejection là API dùng để lắng nghe sự kiện khi 1 Promise reject xảy ra nhưng không được handle, tương đương với function onUnhandledRejection
trong app.js
Sử dụng
Sample Code
index.js
Page({
onLoad(query) {
my.onUnhandledRejection((res) => {
console.log(res.reason);
console.log(res.promise);
});
}
});
app.js
App({
onUnhandledRejection(res) {
console.log(res.reason);
console.log(res.promise);
}
});
API Params
Attributes | Type | Description |
---|---|---|
callback | Function | Callback để catch unhandle reject của Promise. |