微信小程序报错:Error: Page "xxx/xxx/xxx" does not have a method "e1"
明明绑定了方法,而且在其他地方写法没有问题,原因是在微信小程序中for循环里面方法是传递参数,直接绑定参数会导致编译时找不到对应的方法,而此时我们有需要传参,那么我们就需要使用微信小程序提供的公共参数data-*
具体写法:
<view class="image" v-for="(v,i) in 3" :key="i">
<view :data-item="v" :data-index="i" @click="handleClick">{{i}}</view>
</view>
handleClick(e){
console.log(e)
const index= e.currentTarget.dataset.index
const item = e.currentTarget.dataset.item
},