Level 7
it's not getting to this line:
console.log('xxx', store.state.courseContent);
but I need to have this line otherwise my app won't work:
if (store.state.courseContent) {
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
ok so when I click my enter site button, I should get navigated to http://localhost:8080/#/menu
when I click enter, this method is called:
private hideSplash() {
setTimeout(() => {
this.$store.state.showSplash = false;
this.$store.getters.write;
}, 250);
}
this should then be read:
<keep-alive>
<router-view :key="$route.path" default="/menu"/>
</keep-alive>
but it's not changing to /menu here is my router/index.ts file:
import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import store from '@/store/index';
Vue.use(VueRouter)
const routes = new Array<RouteConfig>();
console.log('store.state.courseContentxx: ', store.state.courseContent)
if (store.state.courseContent) {
console.log('xxx', store.state.courseContent);
let menuComponent = 'Menu';
switch(store.state.courseContent.menu._type) {
case 'tiles':
menuComponent = 'Menu';
break;
case 'pages':
menuComponent = 'PageMenu';
break;
}
if (store.state.courseContent.global._navigation === ' navigation') {
routes.push({
path: '/menu',
name: 'menu',
component: () =>
import('../views/' + menuComponent + '.vue'),
});
}
store.state.courseContent.topics.forEach((topic: any) => {
let component = topic._component.charAt(0).toUpperCase() + topic._component.substring(1);
routes.push({
path: topic._uri,
name: topic._uri,
component: () =>
import('../views/' + component + '.vue'),
});
});
}
//
const router = new VueRouter({
mode: 'hash',
base: process.env.BASE_URL,
routes,
scrollBehavior() {
if (document.getElementById('vertical') !== null) {
document.getElementById('vertical')!.scrollIntoView();
}
if (document.getElementById('horizontal') !== null) {
document.getElementById('horizontal')!.scrollIntoView();
}
//go to top of page!
var elem = document.getElementById('app');
if (elem) {
setTimeout(() => {
elem!.scrollTop = 0;
}, 100);
}
}
})
if (store.state.courseContent) {
if (store.state.courseContent.global._navigation === 'navigation' && !store.state.started) {
Vue.nextTick(() => {
router.replace({path: '/menu'});
});
}
}
export default router;
Please or to participate in this conversation.