Skip to main content

my.confirm

confirm

my.confirm là API để hiển thị Confirm popup. Có thể set được title, content, text của Confirm và Cancel button

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 confirm box
contentStringContent message của confirm box
confirmButtonTextStringText của button confirm, mặc định là OK
cancelButtonTextStringText của button confirm, mặc định là Cancel
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">Confirm API</view>
<view class="page-section">
<view class="page-section-title">my.confirm</view>
<view class="page-section-demo">
<button type="primary" onTap="onConfirm">Show Confirm</button>
</view>
</view>
</view>
index.js
Page({
onConfirm() {
my.confirm({
title: 'Alert title',
content: 'Alert content',
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
success: (result) => {
my.alert({ title: `${result.confirm}` });
},
fail: (e) => {
my.alert({ title: `${e}` });
},
complete: () => {
console.log('Complete');
}
});
}
});