Is there a way of detecting when a delimiter on a v-carousel is clicked?
Something like this should work
<button #click="handleClick">...</button>
See event handling docs.
EDIT
assuming you're using the carousel component from vuetify, you could also use their events.
<template>
<v-carousel v-model="model" #change="handleChange">
<v-carousel-item
v-for="(color, i) in colors"
:key="color"
>
<v-sheet
:color="color"
height="100%"
tile
>
<v-row
class="fill-height"
align="center"
justify="center"
>
<div class="display-3">
Slide {{ i + 1 }}
</div>
</v-row>
</v-sheet>
</v-carousel-item>
</v-carousel>
</template>
Related
I want to implement the below carousel in vuetify3? How can I do that?
Use the Grid component inside of the Carousel.
<v-carousel
cycle
height="400"
hide-delimiter-background
show-arrows="hover"
>
<v-carousel-item
v-for="(color, i) in colors"
:key="color"
>
<v-sheet
:color="color"
height="100%"
tile
>
<v-row
style="height:100%;"
align="center"
justify="center"
>
<v-col v-for="(i, index) in 2" :key="index">
<div class="text-h2 d-flex align-center justify-center">Column</div>
</v-col>
</v-row>
</v-sheet>
</v-carousel-item>
</v-carousel>
Docs: https://next.vuetifyjs.com/en/components/grids/
Example: https://codepen.io/alexpetergill/pen/oNMoQae
I use Vuetify framework and create v-img element. When I open contex menu in browser there isn't ordinary image options (Save as, Open image, Copy image). I check it on Firefox and Chrome. How can I fix it? I need to add abilities to save images from page.
Vue 2.6.12, Vuetify 2.3.10
My code snippet:
<template>
<v-img
:src="imageSrc"
:alt="imageAlt"
:width="imageWidth"
:min-height="imageMinHeight"
contain
>
<template v-slot:placeholder>
<v-row
class="fill-height ma-0"
align="center"
justify="center"
>
<v-progress-circular
indeterminate
color="blue-grey lighten-3"
></v-progress-circular>
</v-row>
</template>
</v-img>
</template>
The src of image is an url.
I resolve my issue with default slot of v-img. I put <img> with zero opacity to that slot. So it detected as ordinary image by browser.
My example:
<template>
<v-img
:src="imageSrc"
:alt="imageAlt"
:width="imageWidth"
:height="imageHeight"
contain
>
<template v-slot:default>
<div class="d-flex flex-row">
<v-spacer/>
<img
:src="imageSrc"
:height="imageHeight"
align="center"
class="opacity-0"
>
<v-spacer/>
</div>
</template>
<template v-slot:placeholder>
<v-row
class="fill-height ma-0"
align="center"
justify="center"
>
<v-progress-circular
indeterminate
color="blue-grey lighten-3"
></v-progress-circular>
</v-row>
</template>
</v-img>
</template>
css:
.opacity-0 {
opacity: 0 !important;
}
i've been stuck for hours just to align an item vertically and horizontally in v-card. this image below is what i currently have, i just have to align the item vertically but i dont know how. can anyone help me? thanks in advance
My code :
<div class="pt-3">
<v-card class="pa-3">
<v-row align="center" justify="center" v-bind:style="{ height: deviceHeight * 0.6 + 'px',}">
<v-col class="fill-height" height="500">
<v-card class="text-center grey" height="100%">
<div align="center" justify="center">
<v-icon>mdi-camera</v-icon>
<h3>Upload</h3>
</div>
</v-card>
</v-col>
</v-row>
</v-card>
</div>
computed: {
deviceHeight(){
return this.$vuetify.breakpoint.height;
},
deviceWidth(){
return this.$vuetify.breakpoint.width;
},
},
The align and justify props are used for some Vuetify components, but they won't work on a native HTML div. Instead use the appropriate classes on the v-card...
<v-card class="text-center grey d-flex flex-column align-center justify-center" height="100%">
<div>
<v-icon>mdi-camera</v-icon>
<h3>Upload</h3>
</div>
</v-card>
Demo
v-row behaves as the flex-container and all the props like justify or align or any flex container property will work to it only. Just change ur div to v-row. Althought there is one problem with that is v-row have some negative margin which you can rid off by using no-gutters
<div class="pt-3">
<v-card class="pa-3">
<v-row align="center" justify="center" v-bind:style="{ height: deviceHeight * 0.6 + 'px',}">
<v-col class="fill-height" height="500">
<v-card class="text-center grey" height="100%">
<v-row no-gutters align="center" justify="center">
<v-icon>mdi-camera</v-icon>
<h3>Upload</h3>
</div>
</v-card>
</v-col>
</v-row>
</v-card>
</div>
I have a custom navMenu component that I show twice on my page - once across the top, and once hidden in a v-navigation-drawer until the screen width gets small enough to show it:
<template>
<nav>
<v-app-bar app hide-on-scroll>
<template #extension v-if="$vuetify.breakpoint.smAndUp">
<v-container>
<v-row>
<v-spacer />
<navMenu :items="menuItems" />
<v-spacer />
</v-row>
</v-container>
</template>
<v-app-bar-nav-icon
#click="toggleDrawer()"
v-if="$vuetify.breakpoint.xs"
/>
<img id="logo"
alt="corporate logo"
src="#/assets/full_logo.svg"
width="200"
height="60"
/>
<v-spacer />
<h3 class="info--text headline">My Fancy Website</h3>
</v-app-bar>
<v-navigation-drawer app
v-model="drawer"
v-if="$vuetify.breakpoint.smAndDown">
<navMenu :items="menuItems" />
</v-navigation-drawer>
</nav>
</template>
NavMenu.vue
<template>
<v-col v-for="(item, index) in items" :key="index">
<div v-if="item.children">
<v-menu transition="slide-y-transition" bottom>
<template #activator="{ on }">
<v-btn text v-on="on">{{ item.label }}</v-btn>
</template>
<v-list>
<v-list-item
v-for="(child, j) in item.children"
:key="j"
router
:exact="child.exact"
:to="{ name: child.routeName }"
>
<v-list-item-title class="text-capitalize">
{{ child.label }}
</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
</div>
<div v-else>
<v-btn text router :to="{ name: item.routeName }" :exact="item.exact">
{{ item.label }}
</v-btn>
</div>
</v-col>
</template>
...you may have noticed a fatal flaw in my component: you can't iterate on a root element! Simple enough, wrap it in a <div />, right? Wrong. Wrapping the contents of the template in a div really screws up the layout of the menu items - it renders them stacked vertically instead of horizontally - I think the CSS is looking for a direct child or something.
Is there some alternative element that I can use for the template to satisfy the "one root element" edict that doesn't render any output? Oh, and I tried using the <template /> element already - you can't use it as a root element.
You were so close to finding the answer...
Actually, you should put in a div container, but then just change the display property of the container so the items are still positioned horizontally:
NavMenu.vue
<template>
<div style="display: flex">
<v-col v-for="(item, index) in items" :key="index">
...
I updated your code below. Essentially, all you need to do is to move the entire <v-navigation-drawer> component into your NavMenu.vue file and add the additional drawer prop. Since the <v-navigation-drawer component doesn't actually do much on its own. The #input event listener is only so that you can have the parent component update the drawer value outside of the child component.
<template>
<nav>
<v-app-bar app hide-on-scroll>
<template #extension v-if="$vuetify.breakpoint.smAndUp">
<v-container>
<v-row>
<v-spacer />
<navMenu :items="menuItems" />
<v-spacer />
</v-row>
</v-container>
</template>
<v-app-bar-nav-icon
#click="toggleDrawer()"
v-if="$vuetify.breakpoint.xs"
/>
<img id="logo"
alt="corporate logo"
src="#/assets/full_logo.svg"
width="200"
height="60"
/>
<v-spacer />
<h3 class="info--text headline">My Fancy Website</h3>
</v-app-bar>
<navMenu
v-if="$vuetify.breakpoint.smAndDown"
:drawer="drawer"
:items="menuItems"
#navInput="toggleDrawer()"
/>
</nav>
</template>
NavMenu.vue
<template>
<v-navigation-drawer app :value="drawer" #input="$emit('navInput')>
<v-col v-for="(item, index) in items" :key="index">
<div v-if="item.children">
<v-menu transition="slide-y-transition" bottom>
<template #activator="{ on }">
<v-btn text v-on="on">{{ item.label }}</v-btn>
</template>
<v-list>
<v-list-item
v-for="(child, j) in item.children"
:key="j"
router
:exact="child.exact"
:to="{ name: child.routeName }"
>
<v-list-item-title class="text-capitalize">
{{ child.label }}
</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
</div>
<div v-else>
<v-btn text router :to="{ name: item.routeName }" :exact="item.exact">
{{ item.label }}
</v-btn>
</div>
</v-col>
</v-navigation-drawer>
</template>
<script>
export default {
props: {
drawer: Boolean,
items: {
type: Array,
default: () => []
}
}
};
</script>
I have a parent component with 2 buttons that I want to use as filters. the child component is called inside a v-data-table.
ScanGrid(parent):
<template>
<v-card class="ma-5" v-else>
<v-flex row xs12 class="pa-3 ml-3">
<div class="mr-3 mt-2">
<h3>Regrouper par :</h3>
</div>
<div>
<v-btn-toggle color="success" v-model="groupBy">
<v-btn
text
value="barCode"
class="lowerCase"
v-ripple="{ class: 'success--text' }"
>
Code barre
</v-btn>
<v-btn
text
value="productDef"
class="lowerCase"
v-ripple="{ class: 'success--text' }"
>
Définition de produit
</v-btn>
</v-btn-toggle>
</div>
</v-flex>
<v-card-text>
<v-layout align-center>
<v-data-table
:headers="headers"
:items="items"
item-key="StorageName"
show-expand
single-expand
:expanded="expanded"
hide-default-footer
#click:row="clickedRow"
>
<template v-slot:expanded-item="{ item }">
<td :colspan="12">
<ScanGridCode :item="item"></ScanGridCode>
</td>
</template>
<template v-slot:expanded-item="{ item }">
<td :colspan="12">
<ScanGridDef :item="item"></ScanGridDef>
</td>
</template>
</v-data-table>
</v-layout>
</v-card-text>
</v-card>
</template>
The children components I want to switch using the buttons are called ScanGridCode and ScanGridDef inside templates in v-data-table. I tried to find examples of filtering buttons online but couldn't find anything like what I want to do.
I'm using Vue 2.6.10 with Vuetify 2.1.7
You're almost done already, since you already have the v-btn-toggle set up with v-model="groupBy". All you still need is to add v-if to each template, like:
<template v-if="groupBy=='barCode'" v-slot:expanded-item="{ item }">