We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如下代码 wxml
<view> <wux-accordion-group> <wux-accordion wx:for="{{list}}" wx:key="{{item.id}}" key="{{item.id}}" title="{{item.title}}" > <view> <view class="accordion-content"> {{item.content}} </view> </view> </wux-accordion> </wux-accordion-group> </view>
Page.js
Page({ data:{ list:[] }, onShow:function() { setTimeout(()=>{ this.setData({ list:[{ "id":"abc", "content":"abc", "title":"第一项" },{ "id":"def", "content":"def", "title":"第二项" }] }); },1000); } });
setTimeout模拟请求网络数据 accordion 渲染的列表第一次操作必须点两次才能点开
在不指定key的情况下:
<view> <wux-accordion-group> <wux-accordion wx:for="{{list}}" wx:key="{{item.id}}" title="{{item.title}}" > <view> <view class="accordion-content"> {{item.content}} </view> </view> </wux-accordion> </wux-accordion-group> </view>
点击第二项,展开的却是第一项
目前解决办法是必须指定key,并且需要修改accordion源代码才能工作正常 ··· onTap() { const { index, disabled } = this.data const parent = this.getRelationNodes('../accordion-group/index')[0]
if (disabled || !parent) { return false } parent.onClickItem(index) }
··· 改为 ··· onTap() { const { index, disabled,key } = this.data const parent = this.getRelationNodes('../accordion-group/index')[0]
if (disabled || !parent) { return false } parent.onClickItem(key||index); }
···
The text was updated successfully, but these errors were encountered:
8e3c30e
No branches or pull requests
如下代码
wxml
Page.js
setTimeout模拟请求网络数据
accordion 渲染的列表第一次操作必须点两次才能点开
在不指定key的情况下:
点击第二项,展开的却是第一项
目前解决办法是必须指定key,并且需要修改accordion源代码才能工作正常
···
onTap() {
const { index, disabled } = this.data
const parent = this.getRelationNodes('../accordion-group/index')[0]
···
改为
···
onTap() {
const { index, disabled,key } = this.data
const parent = this.getRelationNodes('../accordion-group/index')[0]
···
The text was updated successfully, but these errors were encountered: