1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <template>
- <div class="todo-footer" v-show="counter.all">
- <label>
- <!-- <input type="checkbox" @change="doneAllHandler" :checked="isAllDone" /> -->
- <input type="checkbox" v-model="isAllDone" />
- </label>
- <span>
- <span>已完成{{ counter.done }}</span> / 全部{{ counter.all }}
- </span>
- <button class="btn btn-danger" @click="removeDoneHandler">
- 清除已完成任务
- </button>
- </div>
- </template>
- <script>
- export default {
- name: "Footer",
- props: ["counter"],
- computed: {
- isAllDone: {
- get() {
- return this.counter.all && this.counter.done === this.counter.all;
- },
- set(v) {
- this.$emit("done-all", v);
- },
- },
- },
- methods: {
- // doneAllHandler(e) {
- // this.doneAllItem(e.target.checked);
- // },
- removeDoneHandler() {
- if (!this.counter.done) {
- alert("没有已完成的任务");
- return;
- }
- if (window.confirm("确定清除?")) {
- this.$emit("remove-done");
- }
- },
- },
- };
- </script>
- <style scoped>
- /*footer*/
- .todo-footer {
- height: 40px;
- line-height: 40px;
- padding-left: 6px;
- margin-top: 5px;
- }
- .todo-footer label {
- display: inline-block;
- margin-right: 20px;
- cursor: pointer;
- }
- .todo-footer label input {
- position: relative;
- top: -1px;
- vertical-align: middle;
- margin-right: 5px;
- }
- .todo-footer button {
- float: right;
- margin-top: 5px;
- }
- </style>
|