vue.js - 如何修复错误 v-bind 表达式的值不能为空 Vue Js

标签 vue.js

我正在尝试 vue js basic 教程,但我在 v-bind 上遇到错误。我使用 v-for 但有这样的错误:

    <template>
    <div class="todo-list">
        <todo-items 
        v-for="todo in todos" // error on here
        :title="todo.title"  // here
        :description="todo.description"/> // on here
    </div>
</template>




<script>
import TodoItems from '@/components/TodoItems.vue'
export default {
    components:{
        TodoItems
    },
    props:{
        todos:{
            required:true,
            type:Array
        }
    }

}
</script>

我不知道我的代码发生了什么,但本教程很好,不会出错。但是我的代码在 v-for 上有错误

这个错误是

Errors compiling template:

v-bind 表达式的值不能为空。在发现 “v-绑定(bind):”

有人能告诉我这个错误吗?

最佳答案

错误是因为数组中至少有一个todo对象的title字段未定义或为空。

如果您提供 todos 数组的确切结构,我将更新我的答案并提供更多详细信息。

关于vue.js - 如何修复错误 v-bind 表达式的值不能为空 Vue Js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58387174/

相关文章:

vue.js - 从 handsontable 访问 vue 实例

javascript - 异步组件会加快加载时间吗?

javascript - v-select 同步修饰符将带有 id 的文本从子级传递到父级

javascript - VueJS 将新对象推送到数组,数据不是 react 性的

javascript - 将错误传递给错误形式组件?

Vue.js 条件 : If contains

javascript - "TypeError: Failed to fetch dynamically imported module"上 Vue/Vite vanilla 设置

javascript - 如何查看Vue组件中的多个属性?

vue.js - Nuxt Vuetify 按钮始终悬停

javascript - 按值分组到数组、includes()、自定义结构