Hello again Stack overflow. I would like to pass a variable to a child component in Vue.
I have already done a little searching and tried the following, based from here stackoverflow
I have also tried the created:
method replacing mounted:
Any thoughts?
Here is my parent component
Subcribe.vue
<template>
<div>
<h1>Subscribe with Stripe</h1>
<StripeSubscriptions :subscription="subscriptionType"></StripeSubscriptions>
</div>
</template>
<script>
import StripeSubscriptions from '../../includes/StripeSubscriptions.vue';
export default {
data(){
return {
subscriptionType: "Monthly"
};
},
components: {
StripeSubscriptions
}
}
</script>
Child component
StripeSubscribe.vue
<template>
<div>
<div ref="card"></div>
<button v-on:click="purchase">Purchase</button>
</div>
</template>
<script>
export default {
props: ['subscription'],
mounted: function () {
this.logThis();
},
methods: {
logThis: function (){
console.log(this.subscription);
},
}
};
</script>
The above console output is: here: undefined