相关部分代码
.wxml 文件
<scroll-view class=“case-scroll-view” scroll-x=“true” scroll-with-animation=’{{scrollViewFlag}}’ scroll-into-view="{{toView}}">
<view class="{{index == 0 ? ‘first-case-view’ : ‘case-view’}}" wx:for="{{caseData}}" wx:key="{{item.id}}" bindtap=“clickCase” data-index="{{index}}" data-picture="{{item.picture}}" data-id="{{item.id}}">
<view class=‘case-box’ id=‘view{{index}}’>
<view class=‘triangle’ wx:if="{{selectedCase == index}}"></view>
<view class=‘case-img-content’>
<block wx:if="{{item.picture}}">
<image class=“case-img” src="{{app.globalData.http}}/{{item.picture}}" mode=“aspectFill”></image>
</block>
<block wx:else>
<image class=“case-img” src="/images/default_pic.png" mode=“aspectFill”></image>
</block>
<view class=‘case-text-view’>
<view class=‘case-text’>{{item.title}}</view>
</view>
</view>
</view>
</view>
<image class=“case-more-img” src=’/images/home/img_more_case.png’ bindtap=‘moreCase’></image>
</scroll-view>
.js 文件
var index = parseInt(event.currentTarget.dataset.index),
picture = event.currentTarget.dataset.picture,
id = event.currentTarget.dataset.id
if(picture != null && picture != undefined && picture != ‘’){
console.log(“selectedCase ==”, index)
if(index == 2){
this.data.toView = ‘view1’
}
if(index == 1){
this.data.toView = ‘view0’
}
this.setData({
selectedCase: index,
casePicture: picture,
caseId: id,
toView: this.data.toView
})
}
这是因为啥???