Vuetify- image Load failed - vue.js

What I want to do is display the image on the page. I have stored its path in backend(MySQL) and after fetching that I am putting it in src of <v-img> but the error occurs saying-
[Vuetify] Image load failed
src: userImage
found in
---> <VImg>
<Anonymous>
<VContent>
<VApp>
<App> at src/App.vue
<Root>
EDIT- this is my Profile.js file
<template>
<v-container >
<div class="headline">Your Profile</div>
<br><br>
<div class="title">Username-</div>
<v-text-field
v-model="user.username"
placeholder="Username"
required
></v-text-field>
<div class="title">Password-</div>
<v-text-field
v-model="user.password"
placeholder="Password"
required
></v-text-field>
<div class="title">Avatar-</div>
<v-img
v-bind:src="userImage"
aspect-ratio="1"
class="grey lighten-2"
max-width="150"
max-height="150"
></v-img>
<div class="title">Email-</div>
<v-text-field
v-model="user.email"
placeholder="Email"
required
></v-text-field>
</v-container>
</template>

Make sure to bind src attribute : <v-image v-bind:src="userImage" />
As you can see here and here, the message is generated as a result of onerror event raised by browser itself so this means something is wrong with the image URL (image with this URL is not on server). Check the URL rendered, try to copy it and open in browser...

Related

How to hide el-form-item__error after field valid?

vue 3.2.31
vee-validate 4.5.10
element-plus 2.1.6
On input event, it shows validation error message properly. But on blur event, it shows is required error message. Also on blur event, even if validation succeeded, it shows is required error message. But when form valid, meta.valid is true and vice versa.
On that time console like follows:
My code:
<VeeForm v-slot="{ isSubmitting, meta }" #submit="submitForm" ref="loginFormObserver" as="div">
<el-form :model="loginForm" ref="loginForm" name="loginForm" size="small" label-position="left" label-width="30%">
<VeeField :rules="'required|email'" name="Username" v-slot="{ field, errorMessage }">
<el-form-item :error="errorMessage" label="Username" required>
<el-input v-model="loginForm.username" type="email" clearable status-icon v-bind="field">
</el-input>
</el-form-item>
</VeeField>
<el-form-item class="text-center">
<el-button class="login-btn" native-type="submit" type="primary" :disabled="!meta.valid || isSubmitting">{{ trans('common.login') }} </el-button>
</el-form-item>
</el-form>
</VeeForm>
If I avoid required attribute fromel-form-item, it works properly. But it removes red asterisk (star) beside labels of required fields.
This might be element-plus validation causing the confusion. You can disable their validation with: :validate-event="false". Which should give you the asterisk and remove the validation behavior from element-plus.
<el-input v-model="loginForm.username" type="email" clearable status-icon v-bind="field" :validate-event="false"></el-input>

How to use router-link in vue js?

I am a beginner to laravel-vue and I have a problem with router-link when I get data from the database to view, all things work correctly, but when I set the path to router link, it does not work.
The error is like:
Invalid prop: type check failed for prop β€œto”. Expected String, Object, got Undefined found in ---> RouterLink
Here is my template code:-
<template>
<v-card>
<v-card-title primary-title>
<div>
<h3 class="headline mb-0">
<router-link :to="data.path">{{data.title}}</router-link>
</h3>
<div class="grey--text">
{{data.created_at}}
</div>
</div>
</v-card-title>
<v-card-text>
{{data.body}}
</v-card-text>
</v-card>
</template>
This is my script:-
<script>
export default {
props:['data']
}
This is the form template view that I read questions inside it:-
<template>
<v-container fluid grid-list-md>
<v-layout row wrap>
<v-flex xs8>
<question v-for="question in questions"
:key="question.path"
:data=question
>
</question>
</v-flex>
sidebar
</v-layout>
</v-container>
</template>
And this is forum script:-
<script>
import question from './question'
export default {
data(){
return{
questions:{}
}
},
components:{question},
created(){
axios.get('/api/question')
.then(res=> this.questions = res.data.data)
.catch(error=>console.log(error.response.data))
}
}
</script>
Hello is says its expcting a string or an object ,, but it received an undefinded .
how to debug this ?
you should go back in steps
1. check the item you accessing maybe console log it : here it looks fine :to="data.path" but data could be empty or undefined
2 . check the prop for changes :it didnt change
3 . check prop passing :data=question aha !: here is the problem i think you are missing quotes here
it should be :data="question"
<question v-for="question in questions"
:key="question.path"
:data="question"
>
4. this would be where you check your request ... so always check your data with console log , how it is formatted what it contains and then use it ,, if its alright than you probably have soime syntax issue

Vee-validate and vuetify checkbox group with v-for

I have some problem with vee-validate, vuetify and v-for.
There is my code :
<ValidationProvider
name="availableLanguages"
rules="required"
v-slot="{ errors }"
>
<v-row>
<v-col
cols="2"
v-for="availableLanguage in availableLanguages"
:key="availableLanguage.label"
>
<v-checkbox
v-model="selectedLanguage"
:label="availableLanguage.label"
:value="availableLanguage.value"
:error="errors.length > 0"
hide-details
#click="setDefaultLanguage"
key="availableLanguage-input"
/>
</v-col>
</v-row>
<v-row>
<v-col
cols="12"
class="errorCheckBox"
>
{{ errors[0] }}
</v-col>
</v-row>
</ValidationProvider>
What is the expected result ?
I have a checkbox group. I want if all checkboxes are unchecked then an error message appear.
What's happened ?
If i don't click once on the first iteration of the v-for loop, the error is not trigger.
Thanks for help.
By default, the Validationprovider doesn't validate as soon as form is rendered, but only does it when the field has been touched. You can use immediate prop to make the field be validated when rendered:
<ValidationProvider
name="availableLanguages"
rules="required"
immediate
v-slot="{ errors }"
>

Getting "Cannot read property 'key' of undefined" in vue template

So in my vue I have a method that takes some data, creates arrays and passes them to another vue file for rendering in the template.
The method
this.shoesData.titles = ['Date', 'Model', 'Price Qty', 'Order Qty', 'Discount Qty'];
this.shoesData.values = [
new Date(this.getShoes.insertDate).toISOString().slice(0, 10).toString(),
this.getShoes.model,
parseFloat(this.getShoes.price).toFixed(0).toString()+' tn',
parseFloat(this.getShoes.order).toFixed(0).toString()+' tn',
parseFloat(this.getShoes.discount).toFixed(0).toString()+' tn'
];
and then I pass shoesData to another file to use it in its template
<CardMultiValue v-if="shoesData.values" :cardData="shoesData" />
in CardMultiValue I have,
<template>
<v-card style="width:100%;height:100%;" :flat="flat" >
<v-card-title class="title" v-if="cardData.Title" style="width:100%;height:30px;justify-content:center;align-items:center;padding:5px;">{{cardData.Title}}</v-card-title>
<v-card-actions v-if="cardData.Title" style='width:100%;height:calc(100% - 30px);padding:5px;' >
<v-container style="padding:0px;height:100%;">
<v-row style="height:100%;">
<v-col :cols="8">
<div v-for="title in cardData.titles" :key="title" :style="'display:flex;align-items:center;font-size:18px;font-weight:bold;height:'+rowHeight+'%;'">
{{title}}
</div>
</v-col>
<v-col :cols="4">
<div v-for="value in cardData.values" :key="value" :style="'display:flex;align-items:center;font-size:18px;height:'+rowHeight+'%;'">
{{value}}
</div>
</v-col>
</v-row>
</v-container>
</v-card-actions>
<v-card-actions v-else style='width:100%;height:100%;padding:5px;' >
<v-container style="padding:0px;height:100%;">
<v-row style="height:100%;">
<v-col :cols="8">
<div v-for="a in cardData.titles" :key="a" :style="'display:flex;align-items:center;font-size:18px;font-weight:bold;height:'+rowHeight+'%;'">
{{a}}
</div>
</v-col>
<v-col :cols="4">
<div v-for="b in cardData.values" :key="b" :style="'display:flex;align-items:center;font-size:18px;height:'+rowHeight+'%;'">
{{b}}
</div>
</v-col>
</v-row>
</v-container>
</v-card-actions>
</v-card>
This is not something complicated, and yet, if this.getShoes.order and this.getShoes.discount both happen to be 0 , I get
TypeError: Cannot read property 'key' of undefined
at sameVnode (vue.runtime.esm.js?2b0e:5811)
at updateChildren (vue.runtime.esm.js?2b0e:6213)
at patchVnode (vue.runtime.esm.js?2b0e:6313)
at updateChildren (vue.runtime.esm.js?2b0e:6187)
at patchVnode (vue.runtime.esm.js?2b0e:6313)
at updateChildren (vue.runtime.esm.js?2b0e:6187)
at patchVnode (vue.runtime.esm.js?2b0e:6313)
at updateChildren (vue.runtime.esm.js?2b0e:6187)
at patchVnode (vue.runtime.esm.js?2b0e:6313)
at updateChildren (vue.runtime.esm.js?2b0e:6187)
This must be a template error, because if I completely remove this.getShoes.order or this.getShoes.discount I get no error. Also, if I dont pass the data to CardMultiValue I get no error.
How can I fix this? Thanks
this.getshoes sounds like a method name. So, perhaps change it to this.getShoes().price or pass the appropriate paramters, if there are any, to it; this.getShoes(someParameter).price

Vuetify Unable to locate target when using attach on v-autocomplete

I want to use autocomplete from Vuetify and I am facing issues there because on my website I have one of the outer divs position: relative the dropdown part of the autocompelete, which is position: absolute, is attaching itself not to the bottom of the input but in random place.
Autocomplete has a prop attach which Specifies which DOM element that this component should detach to. Use either a CSS selector string or an object reference to the element. so I thought I use that and set it to class of my input.
And this works but it causes warning in the console
[Vuetify] Unable to locate target v-autocomplete
found in
---> <VMenu>
<VAutocomplete>
<VCard>
<VApp>
<Root>
Here the link where I reproduced the console warning.
If you are not using v-app component in App.vue, make sure to add data-app attribute to the div with the id app in App.vue.
The result will be like the following:
<template>
<div id="app" data-app>
.... All components, routers, views here ...
</div>
</template>
This worked for me:
<div id="app">
<v-app id="inspire">
<v-card>
<v-card-title class="headline font-weight-regular blue-grey white--text">Profile</v-card-title>
<v-card-text>
<v-subheader class="pa-0">Where do you live?</v-subheader>
<v-autocomplete
v-model="model"
:hint="!isEditing ? 'Click the icon to edit' : 'Click the icon to save'"
:items="states"
:readonly="!isEditing"
:label="`State β€” ${isEditing ? 'Editable' : 'Readonly'}`"
persistent-hint
prepend-icon="mdi-city"
:attach="'#attach'"
>
<template v-slot:append-outer>
<div id="attach"></div>
<v-slide-x-reverse-transition
mode="out-in"
>
<v-icon
:key="`icon-${isEditing}`"
:color="isEditing ? 'success' : 'info'"
#click="isEditing = !isEditing"
v-text="isEditing ? 'mdi-check-outline' : 'mdi-circle-edit-outline'"
></v-icon>
</v-slide-x-reverse-transition>
</template>
</v-autocomplete>
</v-card-text>
</v-card>
</v-app>
</div>