Ok so I created a grid with cards inside that I want to dynamically href and it's working but it's giving me an "undefined" URL path when clicking on any of the cards that showed on the page.
Ive tried using the <template v-slot:item.years="{ item }"> way but its clashing with the <v-hover v-slot:default="{ hover }">
Any help would be appreciated
<template>
<v-container>
<v-row v-for="n in 1" :key="n" no-gutters class="pa-7">
<v-col v-for="n in 6" :key="n" :cols="n === 1 ? 4 : 4">
<v-hover v-slot:default="{ hover }">
## here I am trying to dynamically href the cards so that I can assign URLs outside of the website to them
<a class="text-decoration-none" target="blank" :href="`${years.href}`">
<v-card flat tile class="d-flex">
<v-img
:src="`https://picsum.photos/500/500?image=${n * 5 + 10}`"
:lazy-src="`https://picsum.photos/10/6?image=${n * 5 + 10}`"
class="grey lighten-5"
:aspect-ratio="12/8.5"
>
<v-expand-transition>
<div
v-if="hover"
class="d-flex transition-fast-in-fast-out black darken-2 v-card--reveal display-3 white--text"
style="height: 100%;"
>View Card</div>
</v-expand-transition>
<template v-slot:placeholder>
<v-row class="fill-height ma-0" align="center" justify="center">
<v-progress-circular indeterminate color="grey lighten-5"></v-progress-circular>
</v-row>
</template>
</v-img>
</v-card>
</a>
</v-hover>
</v-col>
</v-row>
</v-container>
</template>
<script>
export default {
data: () => ({
years: [
{
href: "https://www.google.com",
text: "me",
},
{
text: "me",
href: "https://www.bing.com",
},
{
text: "twice",
href: "https://www.facebook.com",
},
],
}),
};
</script>
<style>
.v-card--reveal {
align-items: center;
bottom: 0;
justify-content: center;
opacity: 0.5;
position: absolute;
width: 100%;
}
</style>
You attempted to access years's href property here: :href="years.href", which gives you undefined since years is an array.
Also, you can properly layout your data to something like this:
years: [
{
text: "me",
href: "https://www.google.com",
src: "https://picsum.photos/500/500?image=1",
lazySrc: "https://picsum.photos/10/6?image=1"
},
...
]
and use it like on your html like this:
<v-row no-gutters class="pa-7">
<v-col v-for="(year, i) in years" :key="i" :cols="i === 1 ? 4 : 4">
<v-hover v-slot:default="{ hover }">
<a class="text-decoration-none" target="blank" :href="`${year.href}`">
<v-card flat tile class="d-flex">
<v-img
:src="year.src"
:lazy-src="year.lazySrc"
class="grey lighten-5"
:aspect-ratio="12/8.5"
>
<v-expand-transition>
<div
v-if="hover"
class="d-flex transition-fast-in-fast-out black darken-2 v-card--reveal display-3 white--text"
style="height: 100%;"
>View Card</div>
</v-expand-transition>
<template v-slot:placeholder>
<v-row class="fill-height ma-0" align="center" justify="center">
<v-progress-circular indeterminate color="grey lighten-5"></v-progress-circular>
</v-row>
</template>
</v-img>
</v-card>
</a>
</v-hover>
</v-col>
</v-row>
Here is a sample demo.
Sorry but undefined is what you're going to get. years is an array and you're trying to access the href property of that object in the array. So in order to get the href property, you will need to iterate through the array to access those properties of the object using a v-for.
Related
i am new for vuetify implementing vuetify icon slid console but im confuse.
below console code contained image slide show, using this code i what to implement example image
i want to show like this
<template>
<v-carousel
cycle
height="400"
hide-delimiter-background
show-arrows-on-hover
>
<v-carousel-item
v-for="(slide, i) in slides"
:key="i"
>
<v-sheet
:color="colors[i]"
height="100%"
>
<v-row
class="fill-height"
align="center"
justify="center"
>
<div class="display-3">{{ slide }} Slide</div>
</v-row>
</v-sheet>
</v-carousel-item>
</v-carousel>
</template>
<script>
export default {
data () {
return {
colors: [
'indigo',
'warning',
'pink darken-2',
'red lighten-1',
'deep-purple accent-4',
],
slides: [
'First',
'Second',
'Third',
'Fourth',
'Fifth',
],
}
},
}
</script>
You can define a <v-row/> inside the <v-carousel-item/> then fill it with <v-col/>. Each <v-col/> represents the image/icon and the caption.
<v-carousel
...
>
<v-carousel-item v-for="(slide, i) in 7" :key="i">
<v-row>
<v-col cols="3" v-for="(images, j) in 16" :key="j">
<div class="d-flex flex-column justify-center align-center">
<v-img src="https://via.placeholder.com/50" width="50"/> <!-- can also be `<v-icon/>` -->
<span class="mx-auto text-center caption">Caption</span>
</div>
</v-col>
</v-row>
</v-carousel-item>
</v-carousel>
Here's a sample demo.
i am new in Nuxt.js and Vuetifiy i want to add url link in image tag. if i press image it should open other page link
my page layout
i have specified urls each image have different url like i want to add this url to image
to="/AppMain/Support/Support"
and
to="/UserDash/Profile"
also
to="/AppMain/Entertainment"
how to add this urls in image
my code
<template>
<v-layout style="width: auto;" class="ma-auto">
<v-carousel cycle light height="309" hide-delimiter-background show-arrows-on-hover>
<v-carousel-item v-for="(slide, i) in slides" :key="i">
<v-row>
<v-col cols="3" v-for="(images, j) in slide.images" :key="j">
<div class="d-flex flex-column justify-center align-center">
<v-img :src="images.src" width="30"/>
<span class="mx-auto text-center caption">{{ images.caption }}</span>
</div>
</v-col>
</v-row>
</v-carousel-item>
</v-carousel>
</v-layout>
</template>
<script>
export default {
name: "playground",
data: () => ({
slides: [
{
images: [
{ src: "https://akam.cdn.jdmagicbox.com/images/icontent/newwap/newprotmore/hkm_allcategories.svg", caption: "All Categories"},
{ src: "https://akam.cdn.jdmagicbox.com/images/icontent/newwap/newprotmore/hkm_b2b.svg", caption: "B2B" },
{ src: "https://akam.cdn.jdmagicbox.com/images/icontent/newwap/newprotmore/hkm_shopping.svg", caption: "Shopping" }
]
},
Just wrap it:
Use <nuxt-link />:
<nuxt-link to="#">
<v-img :src="images.src" width="30"/>
</nuxt-link>
If you add the urls to the slide.images array, you can dynamically assign them:
<nuxt-link :to="images.url">
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 can't seem to get two columns the same height with the image centered in Vuetify. I've tried everything and don't know what I'm doing wrong. I hope this image explains what I wan't to achieve.
Below is a snippet, but it doesn't look like what I'm seeing locally. I don't think it really matters as the cols aren't the same height neither.
new Vue({
el: '#app',
vuetify: new Vuetify(),
data: () => ({
showPassword:false,
valid: false,
wachtwoord:'',
wachtwoordRules: [
v => !!v || 'Wachtwoord is vereist',
],
email: '',
emailRules: [
v => !!v || 'E-mail is vereist',
v => /.+#.+\..+/.test(v) || 'Voer een geldig e-mailadres in',
]
}),
methods: {
validate () {
this.$refs.form.validate()
},
},
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vuetify/2.3.2/vuetify.min.js"></script>
<link href="https://unpkg.com/vuetify/dist/vuetify.min.css" rel="stylesheet"/>
<div id="app">
<v-app style="
background-color: #011c40;
background-image: linear-gradient(180deg, #011c40 50%, rgb(26, 65, 115) 100%);
background-size: cover;
">
<v-main>
<v-container fill-height>
<v-row justify="center"
align="center"
no-gutters
class="grey">
<v-col cols="4" class="grey lighten-5">
<v-img src="http://www.dpereira.nl/Er/img/banner.png"></v-img>
</v-col>
<v-col align="center" cols="4" class="grey lighten-5 pa-10">
<v-img class="mb-7" src="https://cdn.vuetifyjs.com/images/logos/vuetify-logo-dark.png" width="200px"></v-img>
<v-form ref="form"
v-model="valid"
>
<v-text-field
v-model="email"
:rules="emailRules"
label="E-mail"
required/>
<v-text-field
:type="showPassword ? 'text' : 'password'"
label="Wachtwoord"
:append-icon="showPassword ? 'mdi-eye' : 'mdi-eye-off'"
#click:append="showPassword = !showPassword"
v-model="wachtwoord"
:rules="wachtwoordRules"
required
/>
<v-checkbox class="mt-0" dense label="Onthoud mij"></v-checkbox>
</v-form>
<v-btn height="50px" :disabled="!valid" tile ripple depressed block color="secondary" #click="validate">Inloggen</v-btn>
<div class="pt-3">
<v-divider></v-divider>
<div class="d-block caption text-center mt-3">Wachtwoord vergeten?</div>
<div class="d-block caption text-center">Nog geen account? Meld u hier aan.</div>
</div>
</v-col>
</v-row>
</v-container>
</v-main>
</v-app>
</div>
At first you need to remove align="center" from the row. Then add contain attribute to v-img tag and set the column to disply:flex. Example:
<v-col cols="4" class="grey d-flex lighten-5">
<v-img contain src="http://www.dpereira.nl/Er/img/banner.png"></v-img>
</v-col>
Neither establish a space immediately before or within a link nor any kind of link works fine while using links within the label attribute - It only checks the box. Using mousewheel works. How to target a new tab with simple leftclick?
<v-checkbox
v-model="checkbox"
:rules="[v => !!v || 'Its required!']"
label=""
required
>
<template v-slot:label>
URL_A
<v-btn href="/#/URL" target="_blank" > URL_B </v-btn>
<navigation-link url="/#/URL" target="_blank">
URL_C
</navigation-link>
</template>
</v-checkbox>
This will not work. When you associate a <label> element with a checkbox <input> (which is what Vuetify is doing behind the scenes), clicking on the label is supposed to toggle the value of the checkbox. It cannot also be a link because then the click action would be ambiguous. If someone clicks the link, should it open the link or toggle the checkbox? It appears that toggling the checkbox wins in this case.
If you need link text to go next to your checkbox, it has to be its own separate element. You can use CSS to get the two elements to line up:
<v-row>
<v-col cols="12">
<v-checkbox
v-model="checkbox1"
color="primary"
:rules="[v => !!v || 'Its required!']"
required
>
<template #label>
This link cannot be clicked
</template>
</v-checkbox>
</v-col>
<v-col cols="12">
<v-checkbox
v-model="checkbox1"
class="pa-0 ma-0"
color="primary"
:rules="[v => !!v || 'Its required!']"
required
style="float: left;"
></v-checkbox>
This link CAN be clicked
</v-col>
</v-row>
There's a working demo in this codeply.
Just use #click.stop on the link:
<v-checkbox v-model="checkbox">
<template v-slot:label>
<a href="/#/URL" target="_blank" #click.stop> URL_A </a>
</template>
</v-checkbox>
It´s done by using a modal:
<v-container v-if="showModal" class="modal-mask white--text">
<transition name="modal">
<v-container >
<v-container class="modal-wrapper">
<v-container class="modal-dialog">
<v-container class="modal-content">
<v-container class="modal-header">
<h4 class="modal-title">Title</h4>
</v-container>
<v-container class="modal-body">
Lorem ipsum
</v-container>
<v-container two-line>
<v-btn color="primary" class="close" #click="showModal=false">
<span>Close</span>
</v-btn>
</v-container>
</v-container>
</v-container>
</v-container>
</v-container>
</transition>
</v-container>
<script>
export default {
data: () => {
return {
showModal: false
}
}
}
</script>
<style>
.modal-mask {
position: fixed;
z-index: 9998;
top: 0%;
left: -10px;
height: 100%;
max-width: none;
background-color: rgba(0, 0, 0, .8);
display: table;
transition: opacity .3s ease;
}
.modal-wrapper {
display: table-cell;
vertical-align: top;
}
.modal-dialog{
overflow-y: initial !important
}
.modal-body{
height: 500px;
overflow-y: auto;
}
</style>