小程序
小游戏
企业微信
微信支付
扫描小程序码分享
4 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
checkbox外面再包一层checkbox-group。事件绑定在checkbox-group上,按文档写
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
bindchanged应该写在checkbox-group上吧?改一下试试。
<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 });
})
还是不行啊,是什么原因,我写的代码太垃圾了吗
本回答由AI生成,可能已过期、失效或不适用于当前情形,请谨慎参考
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
checkbox外面再包一层checkbox-group。事件绑定在checkbox-group上,按文档写
bindchanged应该写在checkbox-group上吧?改一下试试。
<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 });
},
})
还是不行啊,是什么原因,我写的代码太垃圾了吗