antoniandre / wave-ui

A UI framework for Vue.js 3 (and 2) with only the bright side. ☀️
https://antoniandre.github.io/wave-ui
MIT License
546 stars 41 forks source link

Uncaught (in promise) TypeError: this.$refs['tabs-bar'] is undefined #67

Closed agmeeder closed 2 years ago

agmeeder commented 2 years ago

I'm using the w-tabs with dynamic loading of a component for every tab. It works but there is an Error in console.log:

Uncaught (in promise) TypeError: this.$refs['tabs-bar'] is undefined updateSlider wave-ui.es.js:1 beforeMount wave-ui.es.js:1 (wave-ui.es.js:1:114985)

This is my Vue 3 code (typescript with script-setup) for my 'AppSettings.vue' component:

<template>
  <w-card title="Application Settings" title-class="title" class="br-font sh2">
    <w-tabs :items="tabs" fill-bar>
      <template #item-title="{ item }">
        <span class="primary br-font uppercase">
          {{ item.title }}
        </span>
      </template>

      <template #item-content="{ index }">
        <component :is="loadComponent(index)" />
      </template>
    </w-tabs>
  </w-card>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import GeneralSettings from './GeneralSettings.vue'
import LibrixSettings from './LibrixSettings.vue'
import ItrackSettings from './ItrackSettings.vue'

const tabs = ref([{ title: 'General' }, { title: 'Librix' }, { title: 'Itrack' }])

const loadComponent = (index: number) => {
  switch (index) {
    case 1:
      return GeneralSettings
    case 2:
      return LibrixSettings
    case 3:
      return ItrackSettings
  }
}
</script>
antoniandre commented 2 years ago

Hi @agmeeder, Sorry I missed your issue 😅 I've double-checked the same setup and could not see the error. But in case that would still happen, I am now checking if the ref is really existing. in version 2.28.1. Please reopen if not solved! :)

agmeeder commented 2 years ago

Thanks for your answer and the effort. The problem is solved.