解决点击事件传参,打印时却为undefined的问题

话不多说上代码

<scroll-view scroll-y="true" scroll-top="0" :style="{height:indexHeight}"  @scrolltolower="ReachBottom" scroll-with-animation="true">
	<view class="product" v-for="(item,index) in products" :key="item.id" >
		<view class="items">
			<image :src="item.HeadImageURL" mode="aspectFit"></image>
			<view class="namePrice">
				<view class="productName">
					{{item.DisplayName}}
				</view>
				<!-- <view class="deliveryTime">
					{{item.notice}} 
				</view> -->
				<view class="price">
					<view class="sum">								
						<text>¥{{item.MemberPrice}}</text>
						<text>佣金金额:{{item.CommissionPrice}}</text>
					</view>
					<view class="share" @click="openItem(item.HeadImageURL)">
						<image src="../../static/image/share/share.png" mode="aspectFit"></image>
						<text >分享</text>
					</view>
				</view>
			</view>
		</view>
	</view>
	<uni-load-more :status="haveMore" ></uni-load-more>
</scroll-view>
openItem(HeadImageURL){
	console.log(HeadImageURL)
}

这是uniapp项目,在H5上打印正常,但是在微信小程序上打印就显示undefined 这是什么原因呢,item打印不出来,但是index可以正常输出,经过仔细排查,发现   :key="item.id"  中的id与接口返回的ID不匹配,这就相当于是执行了   :key="undefined"  所以输出也就是undefined,以后写代码还是要更加用心才是


版权声明:本文为weixin_45849072原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。