Hello! I set up a project from scratch on laravel + Vue, and started needing html pages migrated. The ”/assets/js/scripts.bundle.js” is not working in the components which are connected via <router-view>. Can you please tell me what this problem could be due to ?
Here is my main blade http://joxi.ru/12M055lt809dwm , this is App.vue http://joxi.ru/v29KGGoTjzJK9r . The components that through router-view don't work scripts. The Navigation and Sidebar components work fine. I use html -> demo1. No errors in the console
Hi Grigor,
Could you please specify the followings?
Here is my main blade http://joxi.ru/12M055lt809dwm , this is App.vue http://joxi.ru/v29KGGoTjzJK9r . The components that through router-view don't work scripts. The Navigation and Sidebar components work fine. I use html -> demo1. No errors in the console
Hi,
By default, we are initializing all scripts on the first-page load. The router-view content is mounted asynchronously, so components used inside a page will not be initialized.
To fix this issue you can move our script initialization code from the page load event to the component mounted function, also you will need to do the same initialization on every route change to initialize page content items.
You can find component initialization file examples in our Metronic Vue version src/core/plugins/keenthemes.ts.
Regards,
Lauris Stepanovs,
Keenthemes Support Team
Hello!
I don't quite understand how to plug the scripts into a component and re-initialise them each time the rota is changed,
Could you please show on my example how to implement this, as I have not worked with type script.
Hi,
Our main components are initialized in file src/js/components/_init.js, using the code below, which will be triggered only when you refresh a page.
// On document ready
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", function() {
KTComponents.init();
});
} else {
KTComponents.init();
}
onMounted(() => {
nextTick(() => {
KTComponents.init();
});
})
router.beforeEach((to, from, next) => {
KTComponents.init();
});
the problem and the question is that I just use html http://joxi.ru/RmzlooNHVRkdDA , I move the needed html into a clean project in laravel + vue as needed
Hi Grigor,
As I mentioned above, in our HTML version, we are making initialization in the page load event and scripts get initialized for every page separately.
You are using a Vue router so most likely your application is a single-page application and the page is loaded only once it is the reason why our initialization solution from HTML version isn't compatible with SPA. To use our scripts you need to add additional vue logic to handle script initialization, check my previous comment.
Regards,
Lauris Stepanovs,
Keenthemes Support Team