useNavigationHelpers.ts 623 B

123456789101112131415161718192021222324
  1. import {onMounted, ref, useContext} from "@nuxtjs/composition-api";
  2. import * as _ from "lodash";
  3. export class UseNavigationHelpers{
  4. public static expansionPanels(){
  5. const {route} = useContext()
  6. const panel = ref()
  7. const activeAccordionId = route.value.query.accordion
  8. onMounted(()=>{
  9. setTimeout(function(){
  10. _.each(document.getElementsByClassName("v-expansion-panel"), (element, index) =>{
  11. if(element.id == activeAccordionId) {
  12. panel.value = index
  13. }
  14. })
  15. if(!panel.value) panel.value = 0
  16. }, 0)
  17. })
  18. return {
  19. panel
  20. }
  21. }
  22. }