属性在Vue组件上未定义

时间:2017-01-23 17:44:40

标签: javascript vue.js

在我的ProjectContainer组件中尝试使用project渲染某些文本时,获得undefined{{project.projectSummary}}的错误。我猜测组件初始化时projectundefined,因为它在我的组件上很好地显示在VueTools中。

enter image description here

接下来,我尝试在父组件上设置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.

的警告

有什么想法?感谢

0 个答案:

没有答案