Skip to main content

my.prompt

prompt

my.prompt là api để hiển thị prompt popup, để user có thể nhập giá tri vào.

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 prompt box
messagestringContent message của prompt box
placeholderstringPlaceholder của text box
alignstringKiểu align cho message:J "left", "center" hoặc "right"
okButtonTextstringText của button ok, mặc định là OK
cancelButtonTextstringText của button cancel, mặc định là Cancel
successFunctionCallback function khi hiển thị prompt box thành công.
failFunctionCallback function khi hiển thị prompt box 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.prompt</view>
<view class="page-section-demo">
<button type="primary" onTap="onPrompt">Show prompt</button>
</view>
</view>
</view>
index.js
Page({
onPrompt() {
my.prompt({
title: 'Prompt',
message: 'This is a long message',
placeholder: 'Input your name',
okButtonText: 'Uhm',
cancelButtonText: 'Ohm',
success: (result) => {
my.alert({
title: JSON.stringify(result)
});
}
});
}
});