mirror of
https://github.com/Dichgrem/Vue.git
synced 2025-12-17 06:02:00 -05:00
style:fmt
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user