[Vue警告]:渲染错误:“ TypeError:无法读取null的属性'id'”

时间:2018-11-21 19:35:15

标签: javascript vue.js

我目前正在构建HackerNews的克隆,并遇到以下错误:

vue.esm.js?efeb:591 [Vue warn]: Error in render: "TypeError: Cannot read property 'id' of null"

found in

---> <Homepage> at src/components/New.vue
       <App> at src/App.vue
         <Root>

我不确定此错误是怎么发生的!外面有人遇到过吗? 这是否意味着错误在New.vue中?这是代码:

<script>
import axios from 'axios'
import Item from '@/components/Item'
export default {
  name: 'Homepage',
  components: {
    'item': Item
  },
  data: function () {
    return {
      err: '',
      stories: []
    }
  },
  created: function () {
    axios.get('https://hacker-news.firebaseio.com/v0/newstories.json')
      .then((result) => {
        this.results = result.data.slice(0, 10)
        this.results.forEach(element => {
          axios.get('https://hacker-news.firebaseio.com/v0/item/' + element + '.json')
            .then((result) => {
              this.stories.push(result)
            })
            .catch((err) => {
              console.log(err)
            })
        })
      })
      .catch((err) => { this.err = err })
  }
}
</script>

0 个答案:

没有答案