我有一個(gè)商店模塊:const state = { todoList: [ { id: 1, title: "Todo One" }, { id: 2, title: "Todo Two" } ]};const getters = { getTodoList: (state) => state.todoList};const actions = {};const mutations = {};export default { state, getters, actions, mutations};我有一個(gè)父元素:<template> <section> <h2>Todo List</h2> <Todo /> <div> <input type="text" name="enterTodo" placeholder="What are you up today ?" /> <button type="submit" @click="addTask" ><i class="fas fa-plus"></i></button> </div> </section></template><script>import Todo from "./Todo.vue";import { mapGetters } from "vuex";export default { name: "TodoContainer", components: { Todo, }, props: [], methods: { addTask: () => { } }, computed: mapGetters(["getTodoList"]),};</script>我有子元素:<template> <div> <div class="todo" v-for="todo in getTodoList" :key="todo.id"> {{ todo.title }} </div> </div></template><script>export default { name: "Todo", props: ["getTodoList"],};</script><style scoped></style>問題在于在子元素中。如何通過父元素將 todoList 從存儲模塊發(fā)送到子元素?沒有真正的教程,缺乏指南,我沒有找到任何與我的特定情況相似的東西。getTodoListundefined
無法將數(shù)組從存儲模塊通過父元素發(fā)送到子元素
慕妹3242003
2022-09-23 21:34:26