WeChat Mini Programs: how to mark the unique attribute of the circular rendered view list and click to change the state!

because the view is rendered in a loop, it doesn"t get it right for a long time

clipboard.png

clipboard.png

use ternary operation to judge the id currently clicked, and then display:none
thought is completely wrong
circular rendering list, all are unified variables
there is no way to modify the attribute
according to id as js does. I really can"t figure it out!

<view class="weike-body-dian" id="{{item.id}}" style="display:{{ item.id== record[mesgid].id ? record[mesgid].display : "" }}"> <view></view></view>

describe the problem clearly first. You have no idea what effect you want to achieve


data is stored in the array. When rendering, tie a data-id, and click the method to determine whether the current id matches the id in the array. If it matches, change the custom attribute state in the array, and choose whether to turn on

by customizing the attribute status.
Menu