style:fmt

This commit is contained in:
dichgrem
2025-11-14 16:57:34 +08:00
parent 7e5c5edd1d
commit e19cf3d551
7 changed files with 63 additions and 57 deletions

View File

@@ -3,7 +3,11 @@
<h1>待办事项</h1>
<div class="input-wrapper">
<input placeholder="请输入您的待办事项,按下回车后即可添加" v-model.trim="newTodo" @keyup.enter="addNewTodo" />
<input
placeholder="请输入您的待办事项,按下回车后即可添加"
v-model.trim="newTodo"
@keyup.enter="addNewTodo"
/>
</div>
<p v-show="isShowMsg" style="color: red">
@@ -55,34 +59,31 @@ p {
</style>
<script>
const WORD_COUNT_LIMIT = 50
const WORD_COUNT_LIMIT = 50;
export default {
data() {
return {
newTodo: "",
countLimit: WORD_COUNT_LIMIT
}
countLimit: WORD_COUNT_LIMIT,
};
},
computed: {
isShowMsg() {
return this.newTodo.length > WORD_COUNT_LIMIT
}
return this.newTodo.length > WORD_COUNT_LIMIT;
},
},
methods: {
addNewTodo() {
if (
this.newTodo.length === 0 ||
this.newTodo.length > WORD_COUNT_LIMIT
) {
return
if (this.newTodo.length === 0 || this.newTodo.length > WORD_COUNT_LIMIT) {
return;
}
this.$emit("addTodo", this.newTodo)
this.newTodo = ""
}
}
}
this.$emit("addTodo", this.newTodo);
this.newTodo = "";
},
},
};
</script>