liangxiaojuan / vue-todos

vue最新实战项目教程,从零开始,一步一个脚印,循序渐进。跟着我一起学习vue吧!
https://liangxiaojuan.github.io/todo
1.94k stars 475 forks source link

https://github.com/liangxiaojuan/vue-todos/blob/master/src/mock/mock.js#L64 #17

Open laughitoff opened 5 years ago

laughitoff commented 5 years ago

Originally posted by @thoth-hank in https://github.com/liangxiaojuan/vue-todos/issues/16#issuecomment-432904621

laughitoff commented 5 years ago

修改后 得到一个新error Uncaught (in promise) TypeError: Cannot read property 'id' of undefined

methods: { init() { // 获取到 $route下params下的id,即我们在menus.vue组件处传入的数据。 const ID = this.$route.params.id; getTodo({ id: ID }).then(res => { //错误在这一行

    let { id, title, count, isDelete, locked, record
    } = res.data.todo;
    // 请求成功,拿到res.data.todo;在将record 赋值到代办单项列表,其它数据赋值到todo对象
    this.items = record;
    this.todo = {
      id: id,
      title: title,
      count: count,
      locked: locked,
      isDelete: isDelete
    };
  });
},