收藏
回答

wx:key 重复问题

框架类型 问题类型 终端类型 微信版本 基础库版本
小程序 Bug 客户端 微信最新版本 2.6.2

- 当前 Bug 的表现(可附上截图)


- 预期表现


- 复现路径


- 提供一个最简复现 Demo


首先我的报错页面,从入口直接进的话是没有问题的,但是在另一个页面点击跳转,进入页面,进入出现我的微信wx:key重复‘,我的数据渲染的也有问题,

而且我请求的数据没有展示,并且页面出现了无关的数据,请问下面的wxml代码有什么问题


代码如下


<import src="../../template/template.wxml" />

<view class="nav">

<view wx:for="{{nav}}" wx:key="unique" class="{{navIndex == index?'navlist':''}}" catchtap='tab' data-index="{{index}}">{{item}}</view>

</view>

<view class="hide" wx:if="{{navIndex == 0  || navIndex == 1  || navIndex == 2 }}" catchtap='hide'>

<view class="{{is_hide == 1?'hide-btner':'hide-btn'}}"></view>

隐藏不再查看的申请

</view>

<!-- 全部 -->


<view class="adopt-list" wx:for="{{applyList}}" wx:key="unique"  wx:if="{{navIndex == 0 && applyList.length != 0}}">

<template is="applyList" data="{{item}}" />

</view>

<!-- 待通过的申请 -->

<view class="pending" wx:if="{{navIndex == 1 ||navIndex == 2}}">

<view class="filtrate">

<view class="title">领养人条件筛选</view>

<view class="experience">

<view class="experience-title">养宠经验</view>

<view class="experience-detail {{experienceIndex == index?'haser':'has'}} " catchtap='setExperience' data-id="{{index}}" wx:for="{{experience}}" wx:key="unique">{{item}}</view>

</view>

<view class="experience">

<view class="experience-title">婚姻状况</view>

<view class="{{maritalIndex == index?'haser':'has'}}" wx:for="{{marriages}}" wx:key="unique" catchtap='setMarriages' data-id="{{index}}">{{item}}</view>

</view>

<view class="experience">

<view class="experience-title">住房情况</view>

<view class=" {{houseIndex == index ? 'haser':'has'}} " wx:for="{{house}}" wx:key="unique" catchtap='setHouse' data-id="{{index}}" data-index="{{index}}">{{item}}</view>

</view>

<view class="extend" wx:if="{{extend}}">

<view class="age">

<view class="experience-title">年龄</view>

<view class=" {{ageIndex == index ?'age-detailer':'age-detail'}} " wx:for="{{age}}" wx:key="unique" data-id="{{index}}" catchtap='setAge'>{{item}}</view>

</view>

<view class="experience">

<view class="experience-title">性别</view>

<view class=" {{genderIndex == index?'haser':'has'}} " wx:for="{{gender}}" wx:key="unique" data-id="{{index}}" catchtap='setGender'>{{item}}</view>

</view>

</view>

<view class="unfold" catchtap='extend' wx:if="{{!extend}}">展开更多

<view class='unfold-btn'></view>

</view>

<view class="button">

<view class="reset" catchtap='reset'>重置</view>

<view class="reset" catchtap='filtrate'>筛选</view>

</view>

</view>

</view>

<view class="hint" wx:if="{{navIndex == 1 & applyList.length != 0}}">领养申请单在创建30天后,送养人未同意也未取消订单,系统自动取消</view>

<view class="hint" wx:if="{{navIndex == 2 & applyList.length != 0}}">通过申请7日后,如未成功签订领养协议,系统将自动取消</view>

<view wx:if="{{(navIndex == 1 & applyList.length != 0) || (navIndex ==2 & applyList.length != 0)}}" class="apply-list" wx:for="{{applyList}}" wx:key="unique">

<template is="applyList" data="{{item}}" />

</view>

<view wx:if="{{navIndex == 3 & applyList.length != 0}}" class="apply-list" wx:for="{{applyList}}" wx:key="unique">

<template is="applyList" data="{{item}}" />

</view>

<view wx:if="{{noData}}"  class="no-data">{{nodataText}}</view>

<view class='white-box' wx:if="{{navIndex == 3}}"></view>

<view class="loading-container" wx:if="{{noData}}">

<template is="loading" data="{{loadingStr}}" />

</view>


回答关注问题邀请回答
收藏

1 个回答

  • 连胜
    连胜
    2019-03-11

    你的wx:key是个固定字符串unique,建议改成唯一标识,最次的方式,也是直接用index,比如 wx:key="{{index}}"


    2019-03-11
    有用
    回复
登录 后发表内容