<scroll-view class="product-info" scroll-y>
<view class="product-property" wx:for="{{selectedFood.foodProperty}}" wx:key="{{index}}">
<view class="product-property-item">{{index}}{{item.propertyName}}</view>
<view class="product-property-select {{propertyDefault == index ? 'active' : ''}}" wx:for="{{item.propertyItem}}" wx:key="{{index}}" data-property-id="{{index}}" catchtap="selectProperty">
{{item}}
</view>
</view>
</scroll-view>
我要通过propertyDefault这个数组选择到对应的属性,我要怎么做?
这个问题我自己解决了,在元素中使用wx:for-index就可以了。也感谢楼上的回复。
selectProperty 事件中,
selectProperty:function(e){
//选中的元素的信息
console.log(e.currentTarget.dataset.dataset)
}
将你想要的值,进行赋值就可以了