1

I'm initializing my app with main.js like so,

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),
});

I'm trying to make use of items within App.vue. But I'm not sure how or if it's passed down into it.

App.vue looks like so...

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

So how do I get data from the constructor and make use of it? Thank you for your help!

1 Answer 1

1

In order to pass props via the render function, you need to provide a context object. See https://v2.vuejs.org/v2/guide/render-function.html#createElement-Arguments

render: h => h(App, {
  props: {
    items: store.items
  }
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.