2017-02-20 62 views
1

在App.vue進口數據,我初始化我的應用程序main.js像這樣,如何使用/從構造

import App from './App.vue'; 

const store = { 
    items: [{ 
     todo: 'Clean Apartment.', 
    },{ 
     todo: 'Mow the lawn!', 
    },{ 
     todo: 'Pick up eggs, milk & flour', 
    }, { 
     todo: 'Watch the big game', 
    }], 
}; 

const app = new Vue({ 
    el: '#app-zone', 
    data: store, // is this not sending the store data into App.vue? 
    render: h => h(App), 
}); 

我試圖讓內App.vue使用items。但我不確定它是如何傳遞給它的。

App.vue看起來是這樣的...

export default { 
    props['items'], // not sure if that's correct 
    created() { 
     console.log(this.items); // always returns undefined 
    } 
} 

那麼,如何從構造函數獲取數據,並利用它?感謝您的幫助!

回答