Home  >  Article  >  WeChat Applet  >  WeChat Mini Program: Interactive Feedback API Description

WeChat Mini Program: Interactive Feedback API Description

高洛峰
高洛峰Original
2017-03-03 10:41:282483browse

wx.showToast(OBJECT)

Display message prompt box
OBJECT parameter description:
[tr] Parameter type required description[/tr]

title String is the content of prompt
icon String No icon, only supports "success" and "loading"
duration Number No The prompt delay time, in milliseconds, default: 1500, the maximum is 10000
success Function No Callback function for successful interface call
fail Function No Callback function for failed interface call
complete Function No The callback function at the end of the interface call (will be executed if the call is successful or failed)

Sample code:

wx.showToast({
    title: '成功'icon: 'success',
    duration: 2000
}) wx.hideToast()


Hide message prompt box

wx.showToast({
    title: '加载中',
    icon: 'loading',
    duration: 10000
}) setTimeout(function() {
    wx.hideToast()
},
2000) wx.showModal(OBJECT)




##Show Modal pop-up window
OBJECT parameter description:[tr]Parameter type required description[/tr]

titleString is the title of promptcontentString YesPrompt contentshowCancelBooleanNoWhether to display the cancel button, the default is truecancelTextStringNoThe text of the cancel button, the default is "Cancel"cancelColorHexColorNoThe text color of the cancel button, the default is "#000000"confirmTextStringNoThe text of the confirmation button, the default is "OK"confirmColorHexColorNoDetermine the text color of the button, the default is "#3CC51F"##successfailcomplete
Function No The interface calls the callback function successfully. When res.confirm==1 is returned, it means the user clicked the OK button
Function No Callback function for failed interface call
Function No The callback function at the end of the interface call (will be executed if the call is successful or failed)
Sample code:

wx.showModal({
    title: '提示',
    content: '这是一个模态弹窗',
    success: function(res) {
        if (res.confirm) {
            console.log('用户点击确定')
        }
    }
}) wx.showActionSheet(OBJECT)


Display operation menu
OBJECT parameter description:
[tr]Required description of parameter type[/tr]

itemListitemColorsuccessfail complete
String Array is the text array of the button. The maximum length of the array is 6
HexColor No The text color of the button, the default is "#000000"
Function No The interface calls the callback function successfully, please see the return parameter description for details
Function No Callback function for failed interface call
Function No The callback function at the end of the interface call (will be executed if the call is successful or failed)
success return parameter description:

[tr]Parameter type description[/tr]

canceltapIndex
Boolean Whether the user cancels the selection
Number The buttons clicked by the user, in order from top to bottom, starting from 0
Sample code:

wx.showActionSheet({
    itemList: ['A', 'B', 'C'],
    success: function(res) {
        if (!res.cancel) {
            console.log(res.tapIndex)
        }
    }
})


More WeChat mini programs: Interactive Feedback API instructions Please pay attention to the PHP Chinese website for related articles!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn