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 settingeditable
fortrue
, enable pop-up window to enter content. When the user clicks the OK button, thesuccess
Gets 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:
-
title
Properties are used to set the title of pop-up window.content
Properties are used to set the prompt content of pop-up windows. -
editable
The property is set totrue
, means that the content in the pop-up window is editable, that is, the input box has been added. -
confirmText
andcancelText
Used to set the text of the OK button and the Cancel button respectively. - exist
success
In the callback function, the corresponding processing is performed according to the user's operation (determine or cancel). If the user clicks the OK button,for
true
, can be passedGet the content entered by the user; if the user clicks the Cancel button,
for
true
。
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!