微信小程序template绑定事件,event值为undefined

发布于 2022-09-11 19:44:47 字数 973 浏览 18 评论 0

template.wxml
<template name="tabbar">
<view class="tabbar_box" style="background-color:{{tabbar.backgroundColor}}; border-top-color:{{tabbar.borderStyle}}; {{tabbar.position == 'top' ? 'top:0' : 'bottom:0'}}">

<block wx:for="{{tabbar.list}}" wx:for-item="item" wx:key="index">
  <view bindtap="forter" data-id="{{item.id}}" class="tabbar_nav" style="width:{{1/tabbar.list.length*100}}%;">
    <image class="tabbar_icon" src="{{item.selected ? item.selectedIconPath : item.iconPath}}"></image>
    <text style="color:{{item.selected ? tabbar.selectedColor : tabbar.color}}">{{item.text}}</text>
  </view>
</block>

</view>
</template>

template上绑定了一个名为forter的事件

template.js
var temp = {
forter: function (event){

//这个event为undefined
console.log(event)

}
}
export default temp

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文