Click the button in the WeChat applet to pop up a pop-up window to input data on the current page

In the WeChat applet, wx.showModal or wx.prompt can be used to pop up a pop-up window on the current page, allowing the user to input data.

When using wx.showModal, you can set the title, content and button text of the modal box. When the user clicks the OK or Cancel button, an object will be returned. The confirm attribute indicates whether the user clicked the OK button, and the cancel attribute indicates whether the user clicked the cancel button. button.

Example:

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

Guess you like

Origin blog.csdn.net/weixin_42579969/article/details/129607494