<view wx:else class="package " data-id="{{item.memberPackageId}}" bindtap="selectPackpage">
<view class="membertime" data-id="{{item.memberPackageId}}" >
<text class="number1" data-id="{{item.memberPackageId}}">{{item.packageTitle}}</text>
<text class="number2" data-id="{{item.memberPackageId}}">个月</text>
</view>
<view class="memberprice" data-id="{{item.memberPackageId}}" >
<view class="reprice" data-id="{{item.memberPackageId}}"><text class="price1" data-id="{{item.memberPackageId}}">活动价</text><text class="price2" data-id="{{item.memberPackageId}}">¥{{item.salePrice}}</text> </view>
<view class="saleprice" data-id="{{item.memberPackageId}}">¥{{item.marketPrice}}</view>
</view>
</view>
我就在最外层设置data-id但是有时候点的时候在点击事件里面获取不到id,得都绑上才行?
不用,tap事件在哪个元素上,data-*就写在那个元素上就行
abc这个变量在页面data里未定义或定义了但是值为undefined,也没有setData或setData是设置成undefined
事件里的dataset就是空的
若是这个abc在页面data里定义了,不管是空字符串或为0或为布尔
在事件里都有这个xxxx的属性
发个代码片段看看
<view wx:else class="package " data-id="{{item.memberPackageId}}" bindtap="selectPackpage">
<view class="membertime" data-id="{{item.memberPackageId}}" >
<text class="number1" data-id="{{item.memberPackageId}}">{{item.packageTitle}}</text>
<text class="number2" data-id="{{item.memberPackageId}}">个月</text>
</view>
<view class="memberprice" data-id="{{item.memberPackageId}}" >
<view class="reprice" data-id="{{item.memberPackageId}}"><text class="price1" data-id="{{item.memberPackageId}}">活动价</text><text class="price2" data-id="{{item.memberPackageId}}">¥{{item.salePrice}}</text> </view>
<view class="saleprice" data-id="{{item.memberPackageId}}">¥{{item.marketPrice}}</view>
</view>
</view>
<view wx:for="{{electAllMember.memberPackageList}}" >
<view wx:if="{{memberPackageId == item.memberPackageId}}" class="package pactive" data-id="{{item.memberPackageId}}" bindtap="selectPackpage">
<view class="membertime" data-id="{{item.memberPackageId}}" >
<text class="number1" data-id="{{item.memberPackageId}}">{{item.packageTitle}}</text>
<text class="number2" data-id="{{item.memberPackageId}}">个月</text>
</view>
<view class="memberprice" data-id="{{item.memberPackageId}}" >
<view class="reprice" data-id="{{item.memberPackageId}}"><text data-id="{{item.memberPackageId}}" class="price1">活动价</text><text class="price2" data-id="{{item.memberPackageId}}">¥{{item.salePrice}}</text> </view>
<view class="saleprice" data-id="{{item.memberPackageId}}">¥{{item.marketPrice}}</view>
</view>
</view>
<view wx:else class="package " data-id="{{item.memberPackageId}}" bindtap="selectPackpage">
<view class="membertime" data-id="{{item.memberPackageId}}" >
<text class="number1" data-id="{{item.memberPackageId}}">{{item.packageTitle}}</text>
<text class="number2" data-id="{{item.memberPackageId}}">个月</text>
</view>
<view class="memberprice" data-id="{{item.memberPackageId}}" >
<view class="reprice" data-id="{{item.memberPackageId}}"><text class="price1" data-id="{{item.memberPackageId}}">活动价</text><text class="price2" data-id="{{item.memberPackageId}}">¥{{item.salePrice}}</text> </view>
<view class="saleprice" data-id="{{item.memberPackageId}}">¥{{item.marketPrice}}</view>
</view>
</view>
</view>