这些警告是什么情况,另外,我的_load_more没有成功被执行,找不到原因

来源:15-2 加载更多数据的判断技巧

迷失的小麦

2020-04-25

图片描述

<view class="container">
  <view class="header">
    <view class="search-container">
      <image class="icon" src="images/search.png"></image>
      <input bindconfirm="onConfirm" placeholder-class="in-bar" placeholder="书籍名称" class="bar" focus="true" value="{{q}}"/>
      <image bindtap="onDelete" class="cancel-img" src="images/cancel.png"></image>
    </view>
    <view bindtap="onCancel" class="cancel">取消</view>
  </view>
  <view wx:if="{{!searching}}">
    <view class="history">
      <view class="title">
        <view class="chunk"></view>
        <text>历史搜索</text>
      </view>
      <view class="tags">
        <block wx:for="{{historyWords}}" wx:key="">
          <v-tag bind:tapping="onConfirm" text="{{item}}"/>
        </block>
      </view>
    </view>
    <view class="history hot-search">
      <view class="title">
        <view class="chunk"></view>
        <text>热门搜索</text>
      </view>
      <view class="tags">
        <block wx:key="" wx:for="{{hotWords}}">
          <v-tag bind:tapping="onConfirm" text="{{item}}"/>
        </block>
      </view>
    </view>
  </view>
  <view wx:if="{{searching}}" class="books-container">
    <block wx:for="{{dataArray}}" wx:key="{{item.id}}">
      <v-book book="{{item}}" class="book"/>
    </block>
  </view>
</view>

_load_more(){
      console.log(123);
      if(!this.data.q)return;//防止没有值就执行
      if(this.data.loading)return;//如果没有执行完上一次请求,这次请求就不会执行
      //const length=this.data.dataArray.length;
      this.data.loading=true;
      bookModel.search(this.getCurrentStart(),this.data.q).then(res => {
        this.setMoreData(res.books);
        // const tempArray=this.data.dataArray.concat(res.books);
        // this.setData({
        //   dataArray:tempArray
        // });
        this.data.loading = false;
      });
    },

也就是说我的下拉加载失败了

写回答

1回答

7七月

2020-04-26

警告是wx:key = "index"

加上这个就可以取消警告了。

这个下拉加载失败,要自己排查下,很难通过代码看出问题。

0
0

纯正商业级微信小程序应用实战,全方位小程序特性讲解

真实数据的高质量小程序项目,学会直接工作

4782 学习 · 2125 问题

查看课程