当前位置:网站首页>梅克尔工作室——HarmonyOS实现列表待办
梅克尔工作室——HarmonyOS实现列表待办
2022-07-29 00:30:00 【晴天不姓晴】
HarmonyOS实现列表待办
一、数据配置文件
在如图datas
路径下放入todolist.js
配置文件

二、HML文件
在HML文件中,使用for
标签从todoList
数据中循环读取数据
主要使用switch
组件实现待办完成

<switch showtext="true" checked="{
{$item.status}}" texton="完成" textoff="待办" class="switch" @change="switchChange($idx)"></switch>
删除按钮
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-m3OxcC2D-1658935411024)(…/…/…/AppData/Roaming/Typora/typora-user-images/image-20220727230742413.png)]
<button class="remove" @click="remove($idx)">删除</button>
完整代码:
<div class="container">
<text class="title">今日打卡</text>
<div class="item" for="{
{todoList}}">
<text class="todo">{
{$item.info}}</text>
<switch showtext="true" checked="{
{$item.status}}" texton="完成" textoff="待办" class="switch" @change="switchChange($idx)"></switch>
<button class="remove" @click="remove($idx)">删除</button>
</div>
<div class="info">
<text class="info-text">您还有</text>
<text class="info-num">{
{todoCount}}</text>
<text class="info-text">件事情待办,加油!</text>
</div>
<div class="add-todo">
<input class="plan-input" type="text"></input>
<button class="plan-btn" onclick="addTodo" @click="addTodo">添加待办</button>
</div>
</div>
三、JS文件
注意:需要从datas
中导入数据配置文件
并且由于预览功能不支持监听键盘输入,就把添加待办的数据写死了
import todoList from "../../common/datas/todoList.js"
export default {
data: {
todoList
},
remove(index){
console.log(index)
this.todoList.splice(index,1)
},
addTodo(){
this.todoList.push({
info: 'IDE工具无法监听键盘输入',
status: false
})
},
computed:{
todoCount(){
let num=0;
this.todoList.forEach(element => {
if(!element.status){
num++
}
});
return num
}
}
}
四、实现

边栏推荐
- RHCE命令练习(一)
- Learning summary of time complexity and space complexity
- Seven SQL performance optimizations that spark 3.0 must know
- Closures and decorators
- LeTax记录\documentclass{},authoryear属性使用
- Flink SQL Hudi actual combat
- ACM SIGIR 2022 | interpretation of selected papers of meituan technical team
- How to check the redis Version (check the redis process)
- Synchronized关键字详解
- 一文读懂Okaleido Tiger近期动态,挖掘背后价值与潜力
猜你喜欢
一篇万字博文带你入坑爬虫这条不归路 【万字图文】
Hilbert transform and instantaneous frequency
Learning summary of time complexity and space complexity
DVWA之SQL注入
Univariate function integration 1__ Indefinite integral
[Jenkins' notes] introduction, free space; Continuous integration of enterprise wechat; Allure reports, continuous integration of email notifications; Build scheduled tasks
Canal real-time parsing MySQL binlog data practice
Self-attention neural architecture search for semantic image segmentation
Canal实时解析mysql binlog数据实战
Linux redis source code installation
随机推荐
log4j动态加载配置文件
Main causes of IT hardware failures and best practices for prevention
代码生成器
Flash reports an error: type object 'news' has no attribute' query 'the view name is duplicate with the model name
北京护照西班牙语翻译推荐
教你一文解决 js 数字精度丢失问题
Summary of process and thread knowledge points 2
[Jenkins' notes] introduction, free space; Continuous integration of enterprise wechat; Allure reports, continuous integration of email notifications; Build scheduled tasks
LeTax记录\documentclass{},authoryear属性使用
Hilbert 变换与瞬时频率
【ManageEngine】助力哈尔滨工程大学实现网络流量一体化监控管理
Oozie job scheduling
SQL injection of DVWA
PLATO上线LAAS协议Elephant Swap,用户可借此获得溢价收益
[MySQL] historical cumulative de duplication of multiple indicators
How to implement the time impact analysis of the construction project?
Log4j dynamic loading configuration file
18 diagrams, intuitive understanding of neural networks, manifolds and topologies
Tupu software appeared at the 2022 Fuzhou digital Expo to jointly create a new digital era
Django reports an error using pymsql module django.db.utils.operationalerror