当前位置:网站首页>Number of wechat applet custom input boxes

Number of wechat applet custom input boxes

2022-06-25 19:54:00 JINYUBAOO

One 、 Knowledge points used

1、 Wechat applet Number() and parseInt()
2、colorui Of var Components
3、wx.setStorageSync Save to local cache

Two 、 Key source code

 Insert picture description here

  <view class="action">
    <button class="cu-btn bg-blue shadow" bindtap="numSteps" style="width:180rpx;"> next step </button>
  </view>

    <view class="cu-item {
    {index>num?'':'text-blue'}}" wx:for="{
    {numList}}" wx:key>
      <text class="num {
    {index==2?'err':''}}" data-index="{
    {index + 1}}"></text>
       {
    {
    item.name}}
      </view>

 Insert picture description here
The number will correspond to several steps
 Insert picture description here

 <view class="cu-bar bg-white solid-bottom">
          <view class="action">
              <text class="cuIcon-titles text-orange"></text>  details 
          </view>
        </view>
          <view  wx:for="{
    {processnum}}" bindtap="tabSelect" data-id="{
    {index}}">
            <view class="cu-form-group">
              <text class="input"> The first {
    {
    index+1}} A step  </text>
            </view>
             ...

        <view class="cu-bar tabbar margin-bottom-xl bg-white">
          <view class="action text-gray add-action">
             <button class="cu-btn cuIcon-add bg-blue shadow" bindtap="add"></button>
                 Release 
           </view>
        </view>
    </view>

The number of steps is stored locally
processnum:

wx.setStorageSync('processnum', e.detail.value)

The basic source of the style used colourUI
But there will be another problem , In this way, the number of local saved steps will be judged by bit , So we also need to convert the string in the input box into the overall number for judgment .


```cpp
numSteps() {
    
    this.setData({
    
      //num: this.data.num == this.data.numList.length - 1 ? 0 : this.data.num + 1,
      processnum : parseInt(wx.getStorageSync('processnum'))
    })
    console.log("processnum:",this.data.processnum)
  
  },

Number(): Can be used to convert any data type to a numeric value ;

parseInt()、parseFloat(): Specifically used to convert strings to numeric values ;

原网站

版权声明
本文为[JINYUBAOO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202190513498329.html