方法一(推荐):

不带if

<ul>
<li
v-for="(item, index) in list"
:key="index"
>
{{ item.title }}
</li>
</ul>

带if

<ul v-for="(item, index) in list" :key="index">
<li v-if="item.checked">{{item.title}}</li>
</ul>
 data () {  // 业务逻辑里面定义的数据
return {
todo: '',
list: [{
title: '111111',
checked: true
}, {
title: '22222',
checked: false
}]
}
}

方法二(通过计算属性):过滤掉不需要的数据,剩下需要的数据再利用v-for循环遍历取出渲染

<h2>进行中</h2>
<ul>
<li v-for="(item, index) in todoList" :key="index">
<input type="checkbox">{{item.title}} ----- <button @click="removeData(index)">删除/button>
</li>
</ul>
<br>
<h2>已完成</h2>
<ul>
<li v-for="(item, index) in doneList" :key="index" >
<input type="checkbox">{{item.title}} ----- <button @click="removeData(index)">删除/button>
</li>
</ul>
data () {  // 业务逻辑里面定义的数据
return {
todo: '',
list: [{
title: '111111',
checked: true
}, {
title: '22222',
checked: false
}]
}
}
computed: {
todoList: function() {
return this.list.filter(function (item) {
return item.checked
})
},
doneList: function() {
return this.list.filter(function(item) {
return !item.checked
})
}
}

最新文章

  1. VS2012 asp.net mvc 4 运行项目提示:&quot;错误消息 401.2。: 未经授权: 服务器配置导致登录失败&quot;
  2. Eclipse自动调整格式
  3. Python成长笔记 - 基础篇 (五)
  4. Xamarin.Forms-VS安装调试错误
  5. mysql 省市联动sql 语句
  6. Struts2命令空间小结
  7. POJ2407(欧拉函数)
  8. linux_inode 和 block
  9. python学习之路网络编程篇(第五篇)-续篇
  10. 强大的测试管理工具---TestTrack Pro
  11. Python深度学习(Deep Learning with Python) 中文版+英文版+源代码
  12. An Overview of End-to-End Exactly-Once Processing in Apache Flink (with Apache Kafka, too!)
  13. 登录注册页面(连接MySQL8.0.15版本)
  14. OC协议、代理的简单使用
  15. C#窗体向另一个窗体实时传值及传值问题
  16. leetcode 443. String Compression
  17. vueJs的简单入门以及基础语法
  18. Spring Cloud常用组件介绍
  19. HDU 4640 状态压缩DP 未写完
  20. Halcon中xld的常见特征的含义总结

热门文章

  1. iview blur事件
  2. Centos7.3安装nexus-3.14.0-04
  3. Django-模型层(单表操作)
  4. vue 使用moment
  5. HashMap不足性分析
  6. Codeforces I. Inna and Nine(组合)
  7. httprunner学习1-环境与登录接口案例
  8. .NET Core项目修改project.json来引用其他目录下的源码等文件的办法 &amp; 解决多框架时 project.json 与 app.config冲突的问题
  9. 【http】Coolie 属性
  10. Ranger安装部署 - solr安装