最近做一个出差记录,是用到textarea,遇到大家都遇到过的问题,什么层级过高,穿透之类的,下面是我经验成果总结出来的,如果有更好的请大神指教,废话不多说,直接上代码:
<textarea wx:if='{{showtextarea}}' value='{{conversation}}' data-show='yes' focus="true" bindblur='ifshowArea'
bindinput='conversation' class='travel_textarea' placeholder='请输入谈话内容' maxlength='150'></textarea>
<view wx:else class='travel_textarea' bindtap='conversation1' style='color:#888888'>{{conversation}}</view>
//textarea谈话内容
conversation:function(e){
var speak = e.detail.value;
this.setData({
conversation:speak
})
},
conversation1:function(){
this.setData({
showtextarea: true
})
if(this.data.conversation=="请输入谈话内容"){
this.setData({ conversation:''})
}
},
ifshowArea(e){
var show = e.currentTarget.dataset.show=="yes"?true:false;
if(show){
this.setData({ showtextarea: false})
}else{ this.setData({showtextarea:true})}
if(this.data.conversation==''){
this.setData({conversation:'请输入谈话内容'})
}
},