hello im using router in my php page content tabs, when i first time enter the route variables undefined and change the route go back it works, when i enter from url same as not defined variable shows in vue dev extension?
app.js
const routes = [
{
path: '/',
component: infotab,
name: 'Info'
},
{ path: '/characters', component: charactertab, name: 'home' },
{ path: '/watch', component: watchtab },
{ path: '/downloads', component: downloadtab }
]
const router = new VueRouter({
routes,
});
var tabb = new Vue({
router,
el: "#app",
}).$mount('#app');
Template script
<script>
export default {
data () {
return {
details: window.infos,
characters: window.characters,
episodes: window.episodes,
}
}
}
</script>
single.blade.php
<div data-v-20e267b2="" data-v-aaf71b06="" class="overview">
<router-view></router-view>
</div>
</div>
<script>
window.infos = {!! json_encode($response) !!};
window.characters = {!! json_encode($apicharacters) !!};
window.episodes = {!! json_encode($episodes) !!};
</script>
It's undefined because the properties on the window
object are not being set.
Instead, you could move the
<script>
window.infos = {!! json_encode($response) !!};
window.characters = {!! json_encode($apicharacters) !!};
window.episodes = {!! json_encode($episodes) !!};
</script>
So it is within the HTML <head>
. This will then set the properties and values before Vue starts up.