微信小程序textarea 限制字数js

                                                         微信小程序textarea 限制字数js_第1张图片

wxss:
.refund{
  width: 96%;
  margin: auto;
  display: flex;
  flex-direction: column;
}
.refund .text{
  color: #333333;
  font-size: 28rpx;
  line-height: 70rpx;
}
.refund .text .xt{
  padding-left: 16rpx;
 color: #999999;
 font-size: 22rpx;
}

/* textarea */
.edit_tkyy{
  width: 96%;
  margin: auto;
  height: 230rpx;
  background: #fff;
  border-radius: 20rpx;
  font-size: 28rpx;
  text-indent: 1em;
  padding: 10rpx;
}
.currentWordNumber{
   color: #999999;
  font-size: 24rpx;
  position: absolute;
  right: 20rpx;
  top: 195rpx;
}

wxml:

  退款说明(选填) 
  


wx.js:
data: {
    isopen:false,
    tihuoWay: '请选择退款原因',
    noteMaxLen: 100,  //字数限制
    currentNoteLen: 0, //输入的字数
  },

input(event) {
    var value = event.detail.value,
      len = parseInt(value.length);
    let that = this;
    this.setData({
      currentNoteLen: len
    })
  }

 

data: {
    noteMaxLen: 500,
    currentNoteLen: 0,
    opinion: "",
  },

onTijiao(e) {
    this.setData({
      opinion: e.detail.value.yijian,
    });
    var data = {
      opinion: this.data.opinion,
    }
    if (this.data.opinion == "") {
      wx.showToast({
        title: '意见不能为空',
        icon: 'loading',
        duration: 1500,
        mask: true
      })
    } else {
      // var that = this;
      // opinionModel.createOpinion(data, (scallback) => {
      //   wx.showToast({
      //     title: '提交成功',
      //     duration: 1500,
      //     mask: true
      //   })
      //   that.setData({
      //     opinion: "",
      //     currentNoteLen: 0
      //   })
      // });
    }
  },

input(event) {
    var value = event.detail.value,
      len = parseInt(value.length);
    let that = this;
    this.setData({
      currentNoteLen: len
    });
  },

 

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