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!