<wxs module="test">
module.exports = {
onSroll: function (evt, ownerInstance) {
console.log('滚动事件触发了');
var ds = evt;
console.log('ds',ds)
// 2. 访问具体的数据
var list = ds.shopList; // 对应 data-shop-list
var input = ds.input; // 对应 data-input
var loading = ds.loading; // 对应 data-loading
console.log(list, input, loading,'获取到的数据')
},
};
</wxs>
<view class="container">
<scroll-view class="shopCard-box" type="nested" scroll-x="{{false}}" scroll-y="{{true}}" enhanced :show-scrollbar="false" refresher-enabled="{{true}}" bind:scroll="{{test.onSroll}}" refresher-triggered="{{scrollView_load}}" bindrefresherrefresh="handleRefresherrefresh" bindscrolltolower="handleScrolltolower" data-shop-list="{{shopList}}" data-input="{{inputValue}}" data-loading="{{loadValue}}" prop="{{inputValue}}">
<block wx:if="{{shopList.length > 0}}">
<shopCard class="shopCard" wx:for="{{shopList}}" wx:item="item" wx:index="index" wx:key="{{item.id}}" bind:tap="handleClick" data-item="{{item}}" item="{{item}}" />
</block>
<view wx:else>当前数据为空</view>
<view class="loading" wx:if="{{loadValue}}">加载中...</view>
</scroll-view>
<!-- <view class="zhe" wx:if="{{showPopup}}" bindtap="closePopup">
<view class="popup" hover-class="none" hover-stop-propagation="false">
</view>
</view> -->
</view>

数据是有的,是因为你获取的对象属性不对,因为(ds.shopList) ds下没有shopList这个属性所以是undefined
正确获取:
ds.currentTarget.dataset.shopList
对象打印出来是 [object Object] ,正常现象,如果要看具体值转一下就好了
JSON.stringify(ds.currentTarget.dataset.shopList)
非对象可直接打印出值,如
ds.currentTarget.dataset.input
没法获取,只能把值传过去