我正在尝试将数据传递给数据函数内部的接收数组,我正在从 firebase 获取数据并希望在 vue 表中显示,但它显示错误
Uncaught TypeError: Cannot set property 'received' of undefined 谁能帮我怎么做?提前致谢
TypeError: Cannot set property 'receieved' of undefined
at eval (Main.vue?48a8:78)
at eval (index.cjs.js?8c4d:4337)
at LLRBNode.inorderTraversal (index.cjs.js?8c4d:2689)
at LLRBNode.inorderTraversal (index.cjs.js?8c4d:2688)
at SortedMap.inorderTraversal (index.cjs.js?8c4d:3139)
at ChildrenNode.forEachChild (index.cjs.js?8c4d:3748)
at DataSnapshot.forEach (index.cjs.js?8c4d:4336)
at eval (Main.vue?48a8:74)
at eval (index.cjs.js?8c4d:4551)
at exceptionGuard (index.cjs.js?8c4d:700)
<script>
import firebase from 'firebase';
export default {
data(){
return{
receieved: [],
}
},
name: 'Main',
mounted(){
var detailRequestRef = firebase.database().ref("nokia_track/current_location");
detailRequestRef.on('value', function(snapshot){
snapshot.forEach(function(child) {
//Retrieve Request Data
var detailRequestData = child.val();
console.log(detailRequestData);
this.receieved = detailRequestData
console.log(receieved);
});
});
}
}
</script>
`