Footer.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <div class="todo-footer" v-show="counter.all">
  3. <label>
  4. <!-- <input type="checkbox" @change="doneAllHandler" :checked="isAllDone" /> -->
  5. <input type="checkbox" v-model="isAllDone" />
  6. </label>
  7. <span>
  8. <span>已完成{{ counter.done }}</span> / 全部{{ counter.all }}
  9. </span>
  10. <button class="btn btn-danger" @click="removeDoneHandler">
  11. 清除已完成任务
  12. </button>
  13. </div>
  14. </template>
  15. <script>
  16. export default {
  17. name: "Footer",
  18. props: ["counter"],
  19. computed: {
  20. isAllDone: {
  21. get() {
  22. return this.counter.all && this.counter.done === this.counter.all;
  23. },
  24. set(v) {
  25. this.$emit("done-all", v);
  26. },
  27. },
  28. },
  29. methods: {
  30. // doneAllHandler(e) {
  31. // this.doneAllItem(e.target.checked);
  32. // },
  33. removeDoneHandler() {
  34. if (!this.counter.done) {
  35. alert("没有已完成的任务");
  36. return;
  37. }
  38. if (window.confirm("确定清除?")) {
  39. this.$emit("remove-done");
  40. }
  41. },
  42. },
  43. };
  44. </script>
  45. <style scoped>
  46. /*footer*/
  47. .todo-footer {
  48. height: 40px;
  49. line-height: 40px;
  50. padding-left: 6px;
  51. margin-top: 5px;
  52. }
  53. .todo-footer label {
  54. display: inline-block;
  55. margin-right: 20px;
  56. cursor: pointer;
  57. }
  58. .todo-footer label input {
  59. position: relative;
  60. top: -1px;
  61. vertical-align: middle;
  62. margin-right: 5px;
  63. }
  64. .todo-footer button {
  65. float: right;
  66. margin-top: 5px;
  67. }
  68. </style>