Forum Replies Created
-
AuthorPosts
-
Acenollari
ParticipantSolution: Use item-value in Vuetify 3 to prevent all rows from expanding at once
In Vuetify 3, when using <v-data-table> with expandable rows, it’s important to specify a unique identifier for each item using the item-value prop. If you don’t, Vuetify can’t properly track which row is being expanded, and as a result, all rows might expand at the same time.
To fix this, just add:
item-value=”menu_item_id”Where menu_item_id is a unique key for each row item. Here’s how it looks in context:
<v-data-table
item-value=”menu_item_id”
:items=”menuSchemaCp[0]?.details”
:headers=”menuHeaders”
show-expand
…
>
This ensures that Vuetify correctly manages the expanded state for individual rows.
February 25, 2025 at 3:24 pm in reply to: When i try to use v-navigation-drawer it shows me this error on my nuxt project #122280Acenollari
ParticipantMake sure to use this structure in app.vue
<template>
<v-app>
<!– Your content here –>
</v-app>
</template>January 28, 2025 at 7:24 am in reply to: When i go from one tab to another web freze and console start to count warnings #122278Acenollari
ParticipantIf an element inside a v-tabs-window-item (e.g., v-autocomplete, v-text-field, etc.) is using an incorrect or undefined variable for v-model, such as:
<v-text-field
label=”Mjeti”
hide-details
density=”compact”
v-model=”item.transporterObj.vehicle_description” <!– This variable might not exist –>
single-line
variant=”outlined”
></v-text-field>When navigating to the tab containing this element, the application may freeze if the specified variable (item.transporterObj.vehicle_description) does not exist or is undefined. This is because v-model tries to bind to a reactive property that isn’t properly initialized, causing unexpected behavior in Vue.
January 10, 2025 at 8:52 am in reply to: v-tabs-window-item shows content of the tab clicked + other content #122273Acenollari
ParticipantSolution:
The issue occurs due to a typo in the code. While VS Code does not highlight this as a syntax error, a closer look reveals that only one of the <v-tabs-window-item> elements is correctly used. The other elements incorrectly use the tag <v-tab-window-item>. These incorrectly used tags display their content at all times, causing the content of other tabs to appear below the first tab’s content.
Here is the corrected code:
<v-tabs v-model=”tab” bg-color=”#2e76bc” color=”white”>
<v-tab v-for=”item in tabItems” :key=”item”>{{ item }}</v-tab>
</v-tabs><v-tabs-window v-model=”tab”>
<v-tabs-window-item></v-tabs-window-item>
<v-tabs-window-item></v-tabs-window-item>
<v-tabs-window-item></v-tabs-window-item>
</v-tabs-window>April 1, 2024 at 6:59 am in reply to: I just created an vue file in which i used Apollo vue and it shows me nothing #9371Acenollari
ParticipantIf you import watchEffect from vue and use it to check if one of the values changes, this method will check every time if the value changes, and if it does you will notice. Before i didn’t use this method the values stayed loading and not showing on my localhost.
<template>
<v-container>
<v-row v-for=”category in categories”>
<v-col>
<v-card :key=”category.category_id” class=”mx-auto card-category” max-width=”400″>
<v-img
class=”align-end text-white”
height=”200″
:src=”category?.photos[0]?.photo_path”
cover
>
<v-row class=”d-flex justify-center title-row”>
<v-card-title class=”card-title”>{{ category.name }}</v-card-title>
</v-row>
</v-img>
</v-card>
</v-col>
</v-row>
</v-container>
</template>
<script lang=”ts”>
import { defineComponent, ref, watchEffect } from ‘vue’
import { useQuery } from ‘@/api/apollo/apolloClient’
import { apolloClient } from ‘@/api/apollo/apolloClient’
import { GET_CATEGORIES } from ‘../api/gql/queries’// Define the shape of the category object directly in the component
interface Category {
category_id: string
code: string
name: string
photos: Array<any>
}// Define a type/interface for the data returned by the GET_CATEGORIES query
interface CategoryData {
categories: Category[]
}export default defineComponent({
name: ‘CategoryList’,
setup() {
let categories = ref<Category[]>([])
const { loading, error, result } = useQuery(GET_CATEGORIES)
console.log(result.value,’=-= result value’)
console.log(loading, result, ‘result’)
// Ensure data is available and not loading
if (!loading.value && result.value) {
console.log(result.value, ‘result’)
categories.value = result.value?.categories ?? []
console.log(categories, ‘categorieeeeeeeees’)
}
watchEffect(() => {
if (!loading.value && result.value) {
categories.value = result.value.categories ?? []
}
})
return {
categories
}
}
})
</script>Acenollari
ParticipantAll this errors can be erased if you make this change on main.ts
import { createApp, h, provide, render } from ‘vue’
import App from ‘./App.vue’
import router from ‘./router’
// import vuetify from ‘./plugins/vuetify’
import ‘vuetify/styles’
import { createVuetify } from ‘vuetify’
import { loadFonts } from ‘./plugins/webfontloader’
import * as components from ‘vuetify/components’
import * as directives from ‘vuetify/directives’
//import { apolloClient } from ‘@/api/apollo/apolloClient’
import { ApolloClient, createHttpLink, InMemoryCache } from ‘@apollo/client/core’
import { DefaultApolloClient } from ‘@vue/apollo-composable’
const vuetify = createVuetify({
components,
directives
})
// HTTP connection to the API
const httpLink = createHttpLink({
// You should use an absolute URL here
uri: ‘http://localhost:4000/graphql’
})// Cache implementation
const cache = new InMemoryCache()// Create the apollo client
const apolloClient = new ApolloClient({
link: httpLink,
cache
})const app = createApp({
setup() {
provide(DefaultApolloClient, apolloClient)
},
render: () => h(App)
})app.use(router).use(vuetify).mount(‘#app’)
-
This reply was modified 2 years, 1 month ago by
Acenollari.
Acenollari
ParticipantVUETIFY
<v-select
class=”select-style”
:items=”items”
id=”locale”
@input=”switchLocale”
v-model=”selectedLocale”
>
<template v-slot:selection=”{ item, index }”>
{{ item.label }}
</template>
<template v-slot:item=”{ item }”>
{{ item.label }}
</template>
</v-select><span style=”text-decoration: underline;”></span>
SCRIPT
return {
items: [
{ value: ‘al’, label: ‘Shqip’, image: ‘albaniaflag.png’ },
{ value: ‘en’, label: ‘English’, image: ‘gbflag.png’ },
],
} -
This reply was modified 2 years, 1 month ago by
-
AuthorPosts