


WeChat applet textarea simple solution
There is no bindchange event for textarea in WeChat applet, so variables cannot be assigned values ??during input.
Although the bindblur event can be used, if you bind the bindblur event and click the button again, the button event will be executed first and then the bindblur event will be executed, so the input value cannot be obtained in the js file,
Solution: Combined with the from form, after inputting into the textarea text box, click the submit button. At this time, the textarea event will be executed first (get the input content of the text box), and then the data submission will be executed, so that the problem is solved
wxml file code:
<form bindsubmit="evaSubmit"> <textarea name="evaContent" maxlength="500" value="{{evaContent}}" class="weui-textarea" placeholder="填寫內(nèi)容(12-500字)"bindblur="charChange" /> <button formType="submit" disabled="{{subdisabled}}" class="weui-btn mini-btn" type="primary" size="mini">提交</button> </form>
js file code:
var app = getApp(); Page({ data:{ evaContent : '' }, onLoad:function(){ }, onReady:function(){ // 頁面渲染完成 }, onShow:function(){ // 頁面顯示 }, onHide:function(){ // 頁面隱藏 }, onUnload:function(){ // 頁面關閉 }, //事件 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('內(nèi)容為12-500個字符','loading',1200); }else{ this.setData({ evaContent : e.detail.value }); } }else{ this.setData({ evaContent : '' }); evaData.evaContent = ''; app.func.showToast('請輸入投訴內(nèi)容','loading',1200); } }, //提交事件 evaSubmit:function(eee){ var that = this; //提交(自定義的get方法) app.func.req('http://localhost:1111/ffeva/complaint?content=''+this.data.evaContent),get,function(res){ console.log(res); if(res.result==='1'){ //跳轉(zhuǎn)到首頁 app.func.showToast('提交成功','loading',1200); }else{ app.func.showToast('提交失敗','loading',1200); } }); } })
Disadvantages:
After this operation, the function will be defective. For example, the number of characters entered in the user's text box cannot be obtained immediately. If there is a better solution, I hope you can learn about it!
For more detailed explanations and simple usage of WeChat mini program textarea, please pay attention to the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)