动态切换获取对象,for循环问题为什么会出现连带数据问题?
如图1,选择了山西回来再选河北,会把山西的数据带回到带回来,但是输出对象没问题如图2,但是图3视图里带了山西的数据,这是bug吗?
this.provinceKey = e.currentTarget.dataset.key;
this.province = this.areaData[this.provinceKey].name;
this.city = '';
this.cityKey = '';
this.areaCity = this.areaData[this.provinceKey].children;
逻辑代码
<block wx:for="{{areaCity}}" wx:key="key">
<view :class="cityKey > 0 && cityKey == key ? 'area-list-item text-red' : 'area-list-item'" :data-key="key" @tap="chooseCity">
<text class="area">{{item.name}}</text>
<icon size="12" color="red" type="success_no_circle" v-if="cityKey > 0 && cityKey == key"></icon>
</view>
</block>
视图代码