Nhảy tới nội dung

my.alert

alert

my.alert là API để hiển thị Alert. Có thể set được title, content, buttonText...

Quét mã để trải nghiệm

Xem code mẫu trên Tini Studio

Demo

Trải nghiệm thử với trình giả lập bên dưới

API Params

Thuộc tínhKiểu dữ liệuMô tả
titlestringTitle của alert box
contentstringContent message của alert box
buttonTextstringText của button, mặc định là OK
successFunctionCallback function khi gọi hàm thành công.
failFunctionCallback function khi gọi hàm thất bại.
completeFunctionCallback function khi hoàn tất gọi hàm bất kể thành công hay thất bại.

Sample Code

index.txml
<view class="page">
<view class="page-description">Alert API</view>
<view class="page-section">
<view class="page-section-title">my.alert</view>
<view class="page-section-demo">
<button type="primary" onTap="onAlert">Show alert</button>
</view>
</view>
</view>
index.js
Page({
onAlert() {
my.alert({
title: 'Alert title',
content: 'Alert content',
buttonText: 'Alert Button',
success: () => {
console.log('Success');
},
fail: () => {
console.log('Fail');
},
complete: () => {
console.log('Complete');
}
});
}
});