I'm using vue with my laravel site and when I click on a button I get taken to another page, the issue I'm having is that
I'm not getting my info from my props.
When I console.log(this.user) in my CreateProduct.vue page I get a null
Here is my code
My app.js
Vue.component('index', require('../js/admin/Index').default);
Vue.component('create-product', require('../js/admin/CreateProduct').default);
if(document.getElementById('app) ! == null){
const app = new Vue({
el: '#app,
data(){
return {
user: null
}
},
methods:{
},
mounted(){
axios.get('/api/getUser').then(response => {
this.user = response.data;
});
}
})
}
My Index.vue
<template>
<div>
<button class="btn btn-sm btn-success" @click="createProduct">Create Product</button>
</div>
</template>
<script>
export default{
props: [],
data(){
return {
}
},
methods: {
createProduct(){
window.location = /admin/create/product';
}
}
}
</script>
Then my create-product.blade.php
@extends('layouts.app')
@section('content')
<div id="app">
<create-product :user="user"/>
</div>
@endsection
and my CreateProduct.vue
<template>
<div>
This is the create product page
</div>
</template>
<script>
export default{
props: ['user'],
data(){
return {
}
},
methods: {
},
mounted(){
console.log(this.user);
}
}
</script>