I've recently implemented Metronic in my Vue app. I've setup demo1 and I can see it has some interesting functions in demo1.js, like _isSidebarCollapse()
What would be the best way to access these throughout my app?
Hi,
May I know which Metronic version are you using? Is it Metronic 9 Tailwind ?
In this case, you can call the global method KTLayout.isSidebarCollapse() to get the sidebar status.
Regards.
Ya, I'm using Metronic 9 Tailwind, but when I run that method on a component I get an error: KTLayout is not defined
Here is an example of what I'm doing:<template>
<div></div>
</template>
<script setup>
console.log(KTLayout.isSidebarCollapse())
</script>
Hi,
Noted, our Vue expert will check it further and get back to you with a solution shortly.
Regards.
Hi,
You can import KTLayout and use isSidebarCollapse() function inside onMounted as shown below.
<script lang="ts" setup>
import { nextTick, onMounted } from "vue";
import KTLayout from "./metronic/app/layouts/demo1.js";
onMounted(() => {
nextTick(() => {
console.log(KTLayout.isSidebarCollapse());
});
});
</script>