微信小程序input框内容被发出后清空

1.首先设置在input里设置value

<view class="weui">

< input class= "weui-input" placeholder= "请输入弹幕" bindblur= "bindInputBlur" value= '{{inputValue}}' / >
view >

然后在Page({ })设置一个变量 inputValue=''

Page({
inputValue=''
data:{

},
bindSendDanmu: function () {
if ( this.data.isRandomColor) {
var color = getRandomColor();
} else {
var color = this.data.numberColor;
}
if (! this.data.inputValue) {
this.videoContext.sendDanmu({
text: this.inputValue,
color: color
})
}
this.setData({
inputValue: '' //将data的inputValue清空
});

})
要注意看value的位置

你可能感兴趣的:(微信小程序开发)