我目前正在构建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>