Detailed explanation and simple use of WeChat applet textarea

Source: Internet
Author: User
This article mainly introduces the details of the small program textarea and the relevant information about the simple use method. here, the code for implementing the instance is attached, and the method for solving the problem that textarea does not have the bindchange event and cannot assign values to the variables during input, for more information, see the simple solution of textarea.

In the applet, textarea does not have a bindchange event, so you cannot assign a value to the variable during input.

Although bindblur events can be used, bindblur events can be bound. if you click a button, the bindblur event is executed before the bindblur event is executed. Therefore, the input value cannot be obtained in the js file,

Solution: combine the from form with the textarea text box input, and then click the submit button. then, the textarea event (get the text box input content) will be executed first, and then the data submission will be executed. This solves the problem.

Wxml file code:


Js file code:

Var app = getApp (); Page ({data: {evaContent: ''}, onLoad: function () {}, onReady: function () {// Page rendering completed }, onShow: function () {// page display}, onHide: function () {// page hiding}, onUnload: function () {// page closed }, // event textBlur: function (e) {if (e. detail & e. detail. value. length> 0) {if (e. detail. value. length <12 | e. detail. value. length> 500) {// app. func. showToast ('Content is 12-1200 characters', 'loading',);} else {this. setData ({eva Content: e. detail. value}) ;}} else {this. setData ({evaContent: ''}); evaData. evaContent = ''; app. func. showToast ('Enter the complaint content', 'loading', 1200) ;}}, // submit the event evaSubmit: function (eee) {var that = this; // submit (custom get method) app. func. req ('http: // localhost: 1111/ffeva/complaint? Content = ''+ this. data. evaContent), get, function (res) {console. log (res); if (res. result = '1') {// jump to the homepage app. func. showToast ('submitted successfully', 'loading', 1200);} else {app. func. showToast ('submission failed', 'loading ', 1200 );}});}})

Disadvantages:

After this operation, the function is defective. For example, you cannot obtain the number of characters entered in the user text box in real time. if you have a better solution, I hope you can learn it!

For more details about the small program textarea and how to use it in a simple way, please follow the PHP Chinese network!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.