Krishnan V S
Krishnan V S

Reputation: 1166

VueJS - how to pass data to a new Vue instance

I have two Vues - Test1 and Test2. From Test1, I am calling Test2 as a new Vue instance. I need to pass a value, am trying to do that using props and data but obviously making some mistake. Below is the code snippet -

Test1

import Test2 from '@/components/Test2.vue';

new Vue({
el: '#app',
components: { Test2 },
props: { varpassedprops: 'TESTINGPROPS'},
data() {
    return {
    varpassed: 'TESTING'
    }
},
template: '<Test2/>',
render: h => h(Test2)
});

Test2

export default {
    props: 'varpassedprops',
    data() {
        return {
            varpassed: ""
        }
    },

In Test2, if I try to use either attribute, I get empty (""). Please let me know what I might be doing wrong, appreciate your help.

Upvotes: 0

Views: 102

Answers (1)

Floyd Watson
Floyd Watson

Reputation: 408

I havent worked with render() to much but believe you pass them like this

render: h => h(Test2, {
props: {
        varpassed: this.varpassed
   })
});

Upvotes: 1

Related Questions