SoFunction
Updated on 2025-04-06

How to use the Add Input Box in uni-app

In uni-app, you can useMethod displays a modal pop-up window and adds an input box there. Here is a sample code:

({
    title: 'Input Information',
    content: 'Please enter your content:',
    editable: true,
    confirmText: 'Sure',
    cancelText: 'Cancel',
    success: function (res) {
        if () {
            ('The content entered by the user:', );
        } else if () {
            ('User canceled input');
        }
    }
});

In the above code, by settingeditablefortrue, enable pop-up window to enter content. When the user clicks the OK button, thesuccessGets the content input by the user in the callback function. If the user clicks the Cancel button, the corresponding processing can be performed.

The following is a detailed explanation of the above code:

  • titleProperties are used to set the title of pop-up window.contentProperties are used to set the prompt content of pop-up windows.
  • editableThe property is set totrue, means that the content in the pop-up window is editable, that is, the input box has been added.
  • confirmTextandcancelTextUsed to set the text of the OK button and the Cancel button respectively.
  • existsuccessIn the callback function, the corresponding processing is performed according to the user's operation (determine or cancel). If the user clicks the OK button,fortrue, can be passedGet the content entered by the user; if the user clicks the Cancel button,fortrue

In this way, it can be used in uni-appMethods add input boxes and get the contents entered by the user.

This is the article about adding input boxes in uniapp. For more related uniapps, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!