mirror of
https://github.com/Dichgrem/Vue.git
synced 2025-12-18 14:31:58 -05:00
refactor:use_pinia
This commit is contained in:
@@ -16,6 +16,36 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const WORD_COUNT_LIMIT = 50;
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
newTodo: "",
|
||||
countLimit: WORD_COUNT_LIMIT,
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
isShowMsg() {
|
||||
return this.newTodo.length > WORD_COUNT_LIMIT;
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
addNewTodo() {
|
||||
if (this.newTodo.length === 0 || this.newTodo.length > WORD_COUNT_LIMIT) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$emit("addTodo", this.newTodo);
|
||||
this.newTodo = "";
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
h1 {
|
||||
color: #409eff;
|
||||
@@ -57,33 +87,3 @@ p {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
const WORD_COUNT_LIMIT = 50;
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
newTodo: "",
|
||||
countLimit: WORD_COUNT_LIMIT,
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
isShowMsg() {
|
||||
return this.newTodo.length > WORD_COUNT_LIMIT;
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
addNewTodo() {
|
||||
if (this.newTodo.length === 0 || this.newTodo.length > WORD_COUNT_LIMIT) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$emit("addTodo", this.newTodo);
|
||||
this.newTodo = "";
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user