這篇文章給大家分享的是有關(guān) 微信小程序組件textarea多行輸入框的示例分析的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。
成都創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比雙城網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫(kù),直接使用。一站式雙城網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋雙城地區(qū)。費(fèi)用合理售后完善,十多年實(shí)體公司更值得信賴。
textarea多行輸入框組件說明:
textarea 多行輸入框。
textarea多行輸入框示例代碼運(yùn)行效果如下:
下面是WXML代碼:
<view class="content"> placeholder: <textarea placeholder="占位符" /> <textarea placeholder="占位符 改變樣式style" placeholder-style= "color:blue"/> <textarea placeholder="占位符 改變樣式class" placeholder-class="placeholdText"/> </view>
下面是WXSS代碼:
.content{ border:1px black solid; margin: 10px; font-size: 10pt; padding: 10px; } textarea{ border: 1px red solid; margin: auto; width:100%; height: 3em; margin-top:5px; padding: 3px; } /*占位符樣式*/ .placeholdText{ font-size: 2em; }
textarea多行輸入框的事件效果圖:
下面是WXML代碼::
<view class="content"> auto-height: <textarea auto-height placeholder="自動(dòng)增高,style.height不生效"/> bindinput="當(dāng)內(nèi)容改變" <textarea placeholder="" bindlinechange="bindlinechange"/> bindfocus:當(dāng)獲取焦點(diǎn) <textarea placeholder="當(dāng)獲取焦點(diǎn)" value="" bindfocus="bindfocus"/> bindblur:當(dāng)失去焦點(diǎn)觸發(fā) <textarea placeholder="當(dāng)失去焦點(diǎn)" bindblur="bindblur"/> </view> 事件觸發(fā): <view class="content" style="color:blue"> {{log}} </view>
下面是JS代碼::
Page({ data:{ log:'事件觸發(fā)' }, //行高改變時(shí) bindlinechange:function(e){ var height=e.detail.height; var heightRpx=e.detail.heightRpx; var lineCount=e.detail.lineCount; this.setData({ log:"height="+height+" | heightRpx="+heightRpx+" | lineCount="+lineCount }) }, //文本失去焦點(diǎn) bindblur:function(e){ var value=e.detail.value; this.setData({ log:"bindblur失去改變.獲取textarea值="+value }) }, //文本獲取焦點(diǎn) bindfocus:function(e){ var value=e.detail.value; this.setData({ log:"bindfocus獲取焦點(diǎn),獲取textarea值="+value }) } })
下面是WXSS代碼::
.content{ border:1px black solid; margin: 10px; font-size: 10pt; padding: 10px; } textarea{ border: 1px red solid; margin: auto; width:100%; height: 3em; margin-top:5px; padding: 3px; }
屬性解析:
下面是WXML代碼:
<!--=======屬性=======--> <!--value:輸入框內(nèi)容--> <textarea value="內(nèi)容"/> <!--placeholder:占位符,對(duì)輸入框內(nèi)容提示--> <textarea placeholder="占位符" placeholder-class="占位符靜態(tài)樣式" placeholder-style="占位符動(dòng)態(tài)樣式"/> <!--disabled:控制標(biāo)簽有效,或者失效狀態(tài),在失效狀態(tài),不能獲取該值--> <textarea disabled="true"/> <textarea disabled/> 等同于 <textarea disabled="false"/> <!--maxlength:內(nèi)容長(zhǎng)度限制,默認(rèn)140--> <textarea maxlength="100"/> <textarea maxlength/> 等同于 <textarea maxlength="140"/> <!--focus:初始化時(shí),獲取輸入焦點(diǎn)(目前開發(fā)工具暫不支持)--> <textarea focus="true"/> <textarea focus/> 等同于 <textarea focus="false"/> <!--auto-focus:當(dāng)界面只有一個(gè)textarea,自動(dòng)獲取焦點(diǎn)--> <textarea auto-focus="true"/> <textarea auto-focus/> 等同于 <textarea auto-focus="false"/> <!--auto-height:是否自動(dòng)增高,設(shè)置auto-height時(shí),style.height不生效--> <textarea auto-height="true"/> <textarea auto-height/> 等同于 <textarea auto-height="false"/> <!--=======事件=======--> <!--bindlinechange:輸入框行數(shù)變化時(shí)調(diào)用 返回參數(shù):height,heightRpx,lineCount--> <textarea bindlinechange="自己定義函數(shù)名"/> <!--bindfocus:當(dāng)獲取焦點(diǎn),可用輸入狀態(tài)時(shí)觸發(fā)--> <textarea bindfocus="自己定義函數(shù)名"/> <!--bindblur:當(dāng)失去焦點(diǎn)觸發(fā)-->
感謝各位的閱讀!關(guān)于“ 微信小程序組件textarea多行輸入框的示例分析”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
分享標(biāo)題:微信小程序組件textarea多行輸入框的示例分析
URL分享:http://chinadenli.net/article21/jsgojd.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、面包屑導(dǎo)航、用戶體驗(yàn)、品牌網(wǎng)站建設(shè)、企業(yè)建站、定制開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)