router.beforeEach
and onMounted
is right thing. If you do not have those global instances then I assume that you haven't included all mandatory theme scripts.<script src="/assets/plugins/global/plugins.bundle.js"></script>
<script src="/assets/js/scripts.bundle.js"></script>
[...]
<link href="/lib/good-template/plugins/global/plugins.bundle.css" rel="stylesheet" type="text/css">
<link href="/lib/good-template/css/style.bundle.css" rel="stylesheet" type="text/css">
<link href="/lib/main.css" rel="stylesheet" type="text/css" />
</head>
<body data-kt-name="good" data-kt-app-layout="light-sidebar" data-kt-app-sidebar-enabled="true" data-kt-app-sidebar-fixed="true" data-kt-app-sidebar-push-header="true" data-kt-app-sidebar-push-toolbar="true" data-kt-app-sidebar-push-footer="true" class="app-default">
<div class="d-flex flex-column flex-root app-root"></div>
<script src="/lib/good-template/plugins/global/plugins.bundle.js"></script>
<script src="/lib/good-template/js/scripts.bundle.js"></script>
<script type="module" src="/src/main.js"></script>
</body>
export default KTComponents;
from _init.js then you can import this instance to your Vue component and initialize it.js/scripts.bundle.js
js/widgets.bundle.js
plugins/global/plugins.bundle.js
KTApp.init();
KTDrawer.init();
KTMenu.init();
KTScroll.init();
KTSticky.init();
KTSwapper.init();
KTToggle.init();
KTScrolltop.init();
KTDialer.init();
KTImageInput.init();
KTPasswordMeter.init();
router.beforeEach
as my problem is that the KT js does not seem to be working when not on the page root.router.beforeEach
should work.router.beforeEach
you can wrap your initialization code with setTimeout
.setTimeout(() => {
// do your initialization here
}, 0);
router.beforeEach
with no success. But I did the same thing in onMounted
in my App.vue and it worked really nice.window.history.replaceState(...);
in case that's interressant to know. I do that on certain pages, and that causes the KTMenu sidebar (in mobile view) and profile popup (in normal view) to stop working. Probably the same reason why it was not working in Vue routes.