在我的ProjectContainer组件中尝试使用project
渲染某些文本时,获得undefined
为{{project.projectSummary}}
的错误。我猜测组件初始化时project
是undefined
,因为它在我的组件上很好地显示在VueTools中。
接下来,我尝试在父组件上设置v-if="resource.project"
<template v-if="resource.project">
<div class="resourceContainer">
<resource-card :resource="resource" :showResourceBtn="showResourceBtn"></resource-card>
<project-container :project="resource.project"></project-container>
</div>
</template>
<script>
import { firebaseAuth, database } from '../../database/database'
import Vue from 'vue'
import VueFire from 'vuefire'
import ResourceCard from '../ResourceCard/ResourceCard'
import ProjectContainer from './Project'
Vue.use(VueFire);
export default {
name: 'Resource',
components: {
ResourceCard,
ProjectContainer
},
data () {
return {
showResourceBtn: true
}
},
computed: {
fbUser () {
return firebaseAuth.currentUser
}
},
created () {
// Load resource
this.$bindAsObject('resource', database.ref('/resources/' + this.$route.params.resourceKey));
}
}
</script>
但这也不起作用。在控制台中给我一个Invalid prop: type check failed for prop "project". Expected Object, got Undefined.
有什么想法?感谢