<view class="container"> <navigation-bar title="代办清单" back="{{false}}" color="black" background="#FFF"></navigation-bar> <scroll-view class="task-list" scroll-y="true"> <block wx:for="{{tasks}}" wx:key="index"> <view class="task-item {{item.completed ? 'completed' : ''}}" data-index="{{index}}"> <checkbox bindchange="toggleComplete" class="checkbox" checked="{{item.completed}}" data-index="{{index}}"></checkbox> <text bindtap="navigateToDetail" data-task-id="{{item.id}}" class="task-name">{{item.title}}</text> <text class="task-date">{{item.create_time}}</text> </view> </block> </scroll-view> <view class="footer"> <view class="input-container"> <input class="input" placeholder="准备做什么?" bindinput="handleInput" value="{{inputValue}}" /> <button class="icon-button" bindtap="handleSubmit"> <image class="icon" src="/assets/send.png" mode="aspectFit" /> </button> </view> </view> </view> // pages/list/list.ts const app = getApp<IAppOption>(); Page({ data: { tasks: [], openid: '', user_id: '', inputValue: '',// 用于存储输入框的值 isLoading: false // 新增一个变量来标记是否正在加载 }, toggleComplete: function (e) { console.log('toggleComplete 被触发', e.detail.value); // const index = e.currentTarget.dataset.index; // const task = this.data.tasks[index]; // const newCompleted = e.detail.value; // 直接使用 e.detail.value // const newTasks = this.data.tasks.map((t, i) => { // if (i === index) { // return { ...t, completed: newCompleted }; // } // return t; // }); // this.setData({ tasks: newTasks }); }, }) 还是不行啊,是什么原因,我写的代码太垃圾了吗
checkbox绑定事件为何无法触发?[图片][图片]
01-27