Javascript 如何从构造函数使用/导入App.vue中的数据
我正在用Javascript 如何从构造函数使用/导入App.vue中的数据,javascript,vue.js,Javascript,Vue.js,我正在用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 b
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
中的项。但我不确定它是如何或是否被传给它的
App.vue看起来像是
export default {
props['items'], // not sure if that's correct
created() {
console.log(this.items); // always returns undefined
}
}
那么如何从构造函数中获取数据并加以利用呢?谢谢你的帮助 要通过render
功能传递props
,需要提供上下文
对象。看
render: h => h(App, {
props: {
items: store.items
}
})