I have the Metronic theme, I disassembled its HTML version and molded it into VUE component format, putting all the JS scripts in the main index.html file. Then I created a view with the HTML code and components for the menu, footer, and sidebar loading the rest and being called within that view. Perfect, everything works fine when I load the system, that is, on redirect. But when I navigate to any other page using the router, even if it's the same as the index, the menus, and all elements stop working. The layout opens correctly, but none of the events like opening, sliding, etc. work, they only start working again when I press F5. I must have done something wrong with the script loading, but what could it have been?
I do not want to use the pre-made Vue package that comes with the theme, as the created folders and components are very different from my project.
Hi,
In our HTML version we initialize our components inside load
event, in SPA versions content is rendered differently and to use our js components you need to move initialization from load
event to onMounted
function.
All components in the HTML version are initialized in js/components/_init.js, you can move this initialization into onMounted
as shown below.
onMounted(() => {
nextTick(() => {
KTComponents.init();
});
});