I'm using Vuetify and to create multiple styled v-card, each card should contain link to a target but only by clicking the card's internal title or image. The problem is that I'm looping over my array of object's and wrapping each v-card with <router-link> so the entire card is clickable. here is the code:
<router-link v-for="recipe in recipes" :key="recipe.title" :to="{path: `recipe/${recipe.title}`}">
<v-card>
<v-img :src="require('../assets/foodpic.jpg')" aspect-ratio="2.75"></v-img>
<v-card-title primary-title>
<div>
<h3 class="headline mb-0">{{ recipe.title }}</h3>
</div>
</v-card-title>
<v-card-actions>
<v-btn flat color="orange" disabled>Share</v-btn>
<v-btn flat color="orange">Explore</v-btn>
</v-card-actions>
</v-card>
</router-link>
i found a way to attach router link to specific element using tags but that only allows me to connect single html element and here i want to use the same link on multiple elements.
any idea how can i modify this code so only the v-img and v-card-title will be linked to the recipe?
hope it works for you
<v-card v-for="recipe in recipes" :key="recipe.title">
<v-img :src="require('../assets/foodpic.jpg')" aspect-ratio="2.75"
:to="{path: `recipe/${recipe.title}`}"></v-img>
<v-card-title primary-title :to="{path: `recipe/${recipe.title}`}">
<div>
<h3 class="headline mb-0">{{ recipe.title }}</h3>
</div>
</v-card-title>
<v-card-actions>
<v-btn flat color="orange" disabled>Share</v-btn>
<v-btn flat color="orange">Explore</v-btn>
</v-card-actions>
</v-card>
i ended up setting it like this:
<v-card v-for="recipe in recipes" :key="recipe.title">
<router-link :to="{path: `recipe/${recipe.title}`}">
<v-img :src="require('../assets/foodpic.jpg')" aspect-ratio="2.75"></v-img>
</router-link>
<v-card-title primary-title>
<div>
<router-link :to="{path: `recipe/${recipe.title}`}">
{{ recipe.title }}
</router-link>
</div>
</v-card-title>
<v-card-actions>
<v-btn flat color="orange" disabled>Share</v-btn>
<v-btn flat color="orange">Explore</v-btn>
</v-card-actions>
</v-card>
Related
I have a card like this:
<v-card :to="groupRoute" class="group-card mx-auto" color="#26c6da" dark max-width="400">
<v-card-title>
<span class="text-h6 font-weight-light d-flex" style="width: 100%">
<span class="name">{{ group.name }}</span>
<span class="flex-grow-1" />
<span class="creation">{{ creation }}</span>
</span>
</v-card-title>
<v-card-text class="text-h6 font-weight-bold">"{{ group.description }}"</v-card-text>
<v-card-actions>
<v-icon class="mr-1">mdi-account</v-icon>
<span class="partecipants subheading mr-2">
<span class="partecipants">{{ group.partecipants.length }}</span>
<span class="mx-1">/</span>
<span class="maxPartecipants">{{ group.maxPartecipants }}</span>
</span>
<v-row align="center" justify="end">
<v-btn class="blue--text text--darken-3" text icon #click="edit">
<v-icon>mdi-pencil</v-icon>
</v-btn>
<v-btn color="red" class="mr-2" icon #click="delete">
<v-icon>mdi-delete</v-icon>
</v-btn>
</v-row>
</v-card-actions>
</v-card>
Note that the only important parts are: :to="groupRoute" and the <v-card-actions> with the two buttons.
The problem here is that the fact that the card has to, overwrites the click methods on the buttons, so even if I click the button and not the whole card, I am redirected to the groupRoute.
Change #click to #click.prevent to trigger preventDefault of the event
I'm creating app in Vue.js with Vuetify library. In app I am dispalaying v-cards, whose titles are of different length. My problem is that I want to display the all title in as many lines as needed. Instead, the title breaks off and there are "..." and only one line. How to change it?
Template:
<v-card max-width="900" class="mb-6">
<v-toolbar flat color="grey darken-2" dark>
<v-toolbar-title align="left">
{{ labels[0].key }}
</v-toolbar-title>
</v-toolbar>
<v-card-text>
<v-text-field
color="grey"
v-model="labels[0].translation"
label="Translation"
>
</v-text-field>
</v-card-text>
</v-card>
After using:
style="overflow: visible"
All text is displayed but still not multiline.
Edit:
After using p instead of v-toolbar-title:
I think you might be better off not using the toolbar at all in this case - it's been designed to have a set of fixed heights (that's why it has the short, prominent and extended prop). You have multiple alternative options, but this might be the easiest:
<v-card max-width="900" class="mb-6">
<v-card-title color="grey darken-2 white--text">
{{ labels[0].key }}
</v-card-title>
<v-card-text>
<v-text-field
color="grey"
v-model="labels[0].translation"
label="Translation"
>
</v-text-field>
</v-card-text>
</v-card>
If you specifically need the dark prop, you can wrap the title in a v-sheet instead:
<v-card max-width="900" class="mb-6">
<v-sheet dark>
<v-card-title>
{{ labels[0].key }}
</v-card-title>
</v-sheet>
<v-card-text>
<v-text-field
color="grey"
v-model="labels[0].translation"
label="Translation"
>
</v-text-field>
</v-card-text>
</v-card>
https://codepen.io/thomaskuhlmann/pen/rNyLXxL
I don't think it's possible ... I searched through Vuetify ... you can change it to ordinary p element not v-toolbar-title
How do I get rid of the padding separating the toolbar from the content?
I would like to achieve the same result like the picture below
Expectation:
What I got:
This is my App.vue file
<v-app>
<app-navigation></app-navigation>
<v-main>
<v-content class="ma-0 pa-0">
<div class="d-flex flex-wrap justify-center" width="900">
<img src="https://picsum.photos/300/300"/>
<img src="https://picsum.photos/600/300"/>
<img src="https://picsum.photos/700/300"/>
<img src="https://picsum.photos/200/300"/>
<img src="https://picsum.photos/400/300"/>
<img src="https://picsum.photos/500/300"/>
</div>
</v-content>
</v-main>
</v-app>
And this is my AppNavigation file - basically, the toolbar component:
<v-toolbar color="transparent" flat>
<router-link to="/">
<v-toolbar-title class="pr-10"> {{ appTitle }} </v-toolbar-title>
</router-link>
<v-btn class="hidden-sm-and-down" text rounded to="/hello"> HELLO </v-btn>
<v-btn class="hidden-sm-and-down" text rounded to="/hello"> HELLO </v-btn>
<v-btn class="hidden-sm-and-down" text rounded to="/about"> About </v-btn>
<v-spacer class="hidden-sm-and-down" ></v-spacer>
<v-btn class="hidden-sm-and-down" outlined rounded to="/sign-up"> SIGN UP</v-btn>
<v-btn class="hidden-sm-and-down" outlined rounded to="/log-in"> LOG IN </v-btn>
</v-toolbar>
Add absolute and width="100%" to the <v-toolbar/>.
<v-toolbar flat color="transparent" absolute width="100%">
...
</v-toolbar>
Demo:
I am trying to get all of my links in three columns in my footer with the copyright line below that. However, my copyright line is showing up in a phantom fourth column and it overlaps the third column if the screen width gets too small. If I use the same layout in my content section, I get the three columns.
Here is my footer component:
<template>
<div>
<v-footer color="primary lighten-1" padless>
<v-row justify="center">
<v-col cols=4>
<div class="my-1">
<v-btn color="white" text rounded>
Contact Us
</v-btn>
</div>
<div class="my-1">
<v-btn color="white" text rounded>
Contact Us
</v-btn>
</div>
</v-col>
<v-col cols=4>
<div class="my-1">
<v-btn color="white" text rounded>
Data Sources
</v-btn>
</div>
</v-col>
<v-col cols=4>
<div class="my-1">
<v-btn color="white" text rounded>
Browse Maps
</v-btn>
</div>
</v-col>
</v-row>
<v-row>
<v-col cols="12">
<p class="text-center grey--text text--lighten-2">Copyright 2020, </p>
</v-col>
</v-row>
</v-footer>
</div>
<template>
On a possibly related note, why do I have to wrap each button in a div with a my-? class to get the buttons to stack vertically.
Edit:
I am using Vuetify v2.2.11.
Here is a screenshot of what it is doing:
Here is what I want:
My buttons that are within the same column are showing up side/side unless I either wrap them in the my-? classed div or there is not enough room in the column to display them side/side. I would like them stacked on top of each other in every screen size. And of course I only want the three columns for my buttons
A v-row only works as expected if wrapped in a v-container.
Add a <v-container fluid> around your v-rows and it should work just fine. Fluid is described as "Removes viewport maximum-width size breakpoints", thus removing the horizontal padding.
The whole thing would look like this in the end:
<template>
<div>
<v-footer color="primary lighten-1" padless>
<v-container fluid>
<v-row class="text-center">
<v-col cols="4">
<div class="my-1">
<v-btn color="white" text rounded>
Contact Us
</v-btn>
</div>
<div class="my-1">
<v-btn color="white" text rounded>
Contact Us
</v-btn>
</div>
</v-col>
<v-col cols="4">
<div class="my-1">
<v-btn color="white" text rounded>
Data Sources
</v-btn>
</div>
</v-col>
<v-col cols="4">
<div class="my-1">
<v-btn color="white" text rounded>
Browse Maps
</v-btn>
</div>
</v-col>
</v-row>
<v-row>
<v-col cols="12">
<p class="text-center grey--text text--lighten-2">
Copyright 2020,
</p>
</v-col>
</v-row>
</v-container>
</v-footer>
</div>
</template>
I'm using vuetify to design a 'card' component.
I have a parent div with a child button. Now, when I click the button, the ripple effect on the div is triggered.
How can I fix this?
<template>
<div>
<v-card v-ripple="true">
<h3>
<v-card-title>{{ title }}</v-card-title>
</h3>
<v-layout row>
<v-flex grow>
<v-card-text>
{{ plaats }}
<br />
{{ sub_title }}
</v-card-text>
</v-flex>
<v-flex shrink>
<v-card-actions>
<v-btn small color="blue" fab>
<v-icon medium color="white">mdi-calendar</v-icon>
</v-btn>
<v-btn small color="green" fab>
<v-icon medium color="white">mdi-calendar-check</v-icon>
</v-btn>
<v-btn small color="red" fab>
<v-icon medium color="white">mdi-calendar-remove</v-icon>
</v-btn>
</v-card-actions>
</v-flex>
</v-layout>
</v-card>
</div>
</template>
The solution was indeed Event.stopPropagation but I had to add it to the mousedown action.
So #mousedown.stop and then add your function with #click.stop="null" as #Frank mentioned before.
Note #mousedown event will not fire on mobile, thus we also need to
add #touchstart.
Codepen
<v-list>
<v-list-tile :ripple="true" #click="">
<v-list-tile-action>
<v-btn
#click.stop=""
#mousedown.stop=""
#touchstart.stop=""
>Click</v-btn>
</v-list-tile-action>
<v-list-tile-content class="pl-5">
Click tile
</v-list-tile-content>
</v-list-tile>
</v-list>
You're looking for Event.stopPropagation. Add #click.stop="null" to your button(s). Of course you can/should replace null with your own method.
if your vuetify css is separate, not in your app.js,
the solution that worked for me is to put the app.js script outside the body, when it is inside the js loads first than the vuetify css.
<!-- ripple error occurs randomly -->
<script src="{{ URL::asset('js/vLib.js') }}" defer></script>
</body>
<!-- Should be outside the body -->
</body>
<script src="{{ URL::asset('js/vLib.js') }}" defer></script>