link2466 link2467 link2468 link2469 link2470 link2471 link2472 link2473 link2474 link2475 link2476 link2477 link2478 link2479 link2480 link2481 link2482 link2483 link2484 link2485 link2486 link2487 link2488 link2489 link2490 link2491 link2492 link2493 link2494 link2495 link2496 link2497 link2498 link2499 link2500 link2501 link2502 link2503 link2504 link2505 link2506 link2507 link2508 link2509 link2510 link2511 link2512 link2513 link2514 link2515 link2516 link2517 link2518 link2519 link2520 link2521 link2522 link2523 link2524 link2525 link2526 link2527 link2528 link2529 link2530 link2531 link2532 link2533 link2534 link2535 link2536 link2537 link2538 link2539 link2540 link2541 link2542 link2543 link2544 link2545 link2546 link2547 link2548 link2549 link2550 link2551 link2552 link2553 link2554 link2555 link2556 link2557 link2558 link2559 link2560 link2561 link2562 link2563 link2564 link2565 link2566 link2567 link2568 link2569 link2570 link2571 link2572 link2573 link2574 link2575 link2576 link2577 link2578 link2579 link2580 link2581 link2582 link2583 link2584 link2585 link2586 link2587 link2588 link2589 link2590 link2591 link2592 link2593 link2594 link2595 link2596 link2597 link2598 link2599 link2600 link2601 link2602

[Vue.js] Whats the most comprehensive validation library for vue.js

I’m want to run a custom validation rules based on different events in the page as the following,
1. On Keydown: when I’m checking the context *like emails format
2. On Blur: when I’m checking if the username is already taken or not
3. On Submit: like all the required elements in the form.
The form is dynamic and I’m using tailwind components build in VUE.
Its working either on Live or before Submit. How can I make that customization? any comprehensive examples or recommendations?

Solution :

I can recommend vuelidate and VeeValidate. Check out the following documentations and examples:

https://vuejs.org/v2/cookbook/form-validation.html
https://vuelidate.netlify.com/#getting-started
https://baianat.github.io/vee-validate/

[Vue.js] twitter intent share japanese text not working in IE11

there is a simple share button by which twitter share url & text

https://twitter.com/intent/tweet?text=15 &hashtags=hello&url=encodeURIComponent(‘https://google.com')

This is working in every browser but when IE11 its not working. Showing 400 bad request. Can anybody help me.

Sometimes not show 400 bad request but japanese text showing as question mark

When I open this URL into chrome then it works, after that if I copy this URL from Chrome then also work in IE but direct URL not works. Perhaps URL encoding issue. please help

Solution :

you need to %-Encode the URL to UTF8. IE 11 does not do this.
Here’s a relevant SO question: Why Internet Explorer doesn’t url-encode the urls?

Solution 2:

Finally The issue fixed. there is encoded text also like URL and its working in IE11 also. So I use encodeURIComponent(‘Japanese text’) like below & then working

https://twitter.com/intent/tweet?text=encodeURIComponent(‘15 ‘)&hashtags=hello&url=encodeURIComponent(‘https://google.com')

[Vue.js] how to make height evenly vue components inside col with bootstrap? h-100 doesn't work as intended

This question is an exact duplicate of:

how to make height evenly vue.js components inside col with bootstrap? [duplicate]

A wanted to put a margin between components, so I put it inside col inside row.
The cols themselves stretched evenly, but not the vue.js components inside it.
w/o h-100

row.align-items-start or h-100 didn’t work well for my case.
.item (height: 90%;} made the red box strech, but the texts were remaining same.
If I didn’t put h-100 in the component and only at App.vue, the text remained same at the middle, and it was also using up my margin. h-100 @ app

When apply style=”position: absolute; bottom: 0; “ align=”center”it goes down but center alignment disapear and the img is still on top, not the center.

tldr:

h-100 occupy the margin area.
images aren’t positioning vertically center.

@ App.vue

<div class=”row row-eq-height”>
<div class=”col-6 col-sm-4” v-for=”(category, index) in categories”>
<cmp-category-menu class=”my-3 h-100”></cmp-category-menu>
</div>
</div>

@CategoryMenu.vue

<div class=”card text-center”>
<img v-bind:src=”category.img” alt=”category.name” class=”card-img-top”>
<div class=”card-body”>
<p class=”card-title”>{ category.name }</p>
</div>
</div>

the result I want: https://i.imgur.com/oMtJsPu.png

Solution :

Zim’s deleted comment worked out perfectly for me!

link for example

[Vue.js] Is it still possible to use both vuetify and vue-bootstrap?

there is been using vue-bootstrap but I was thinking of switching to vuetify. However, I found out for some components, vue-bootstrap is much easier to integrate with backend.
So now I’m thinking of using both depending on the component. Does it still make sense to use both vue-bootstrap and vuetify on the same project? Or is there a problem if I use both frameworks?

Solution :

Yes, it does not cause any issues to use both libraries in parallel. I tried it before within a medium size project without facing any problems.

[Vue.js] Vuetify access Vue instance data with v-for in v-data-table

How to access the vue.js instance data using v-for inside Vuetify’s v-data-table

Issue: Data not displayed under Table Header 2

<v-data-table
:headers=”headers”
:items=”tabular.table” :hide-actions=”true”
class=”elevation-1”
\>
<template v-slot:items=”props” v-for=”(table, index) in tabular.table” >
<td :class=”{‘warn’ : warning(index)}”>{ props.item.name }</td>
<td v-for=”inner in table.inner” :class=”{‘warn’ : !inner.data}”>{ props.item.inner.data }</td>
</template>
</v-data-table>

tabular:{table: [
{
name: ‘Table Data 1’,
inner: [{data: “false”}]
}

fiddle:
https://jsfiddle.net/m09uLgaz/1/

Solution :

You are supposed to use

<template v-slot:items=”props” v-for=”(table, index) in tabular.table”>
<td :class=”{‘warn’ : warning(index)}”>{ props.item.name }</td>
<td v-for=”inner in props.item.inner” :class=”{‘warn’ : !inner.data}”>{ inner }</td>
</template>

Instead of

<td v-for=”inner in table.inner” :class=”{‘warn’ : !inner.data}”>{ props.item.inner.data }</td>

You don’t need to use props.item.inner because you have that reference in inner. Also in the object inner use true and false as Boolean and not as string.

Edited JSFiddle link https://jsfiddle.net/0pw3264a/

Updated fiddle for custom sort https://jsfiddle.net/qtLujh0e/

[Vue.js] @vue/cli build dist/ folder doesn't render when hosted as a sub-directory

when making a simple 2 page website with @vue/cli / vue.js version 3.5.5.

So far so good, when i run the website locally with npm run serve and then create my dist/ folder with npm run build .

When I add the files from the dist/ folder to the root of my hosting and access the production environment on http://www.my-website.com the page renders and runs normally.

However to host the app in the sub-directory but this messes up the routes as the index.html doesn’t render.
When accessing http://www.my-website.com/dist : the index.html is returned blank and with error messages in the console:

app.a1183de6.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)

chunk-vendors.ff22d1fb.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)

about.ad763791.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)

app.a1183de6.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)

Provide background including what you’ve already tried

I’ve spent hours and hours searching and the most common thing is to create a vue.config.js file and to change the root path into a sub-directory instead

module.exports = {
baseUrl: process.env.NODE_ENV === ‘production’
? ‘/dist/‘
: ‘/‘
}

I also tried this but it doesn’t work:

// module.exports = {
// publicPath:’ /dist/ ‘
// }

I put the vue.config.js file at the root of the project folder as indicated but it seems to be ignored on npm run build

Describe the expected and actual results:

I would like to render my vue-app in a sub-directory such as :

http://www.website.com/dist

But right now, i get a blank index.html page and error messages in the console when i host my project in a sub-directory. the project runs fine if i host it in the root

Solution :

nvm… it’s working now ….

Created in root of project: vue.config.js

Added the following:

module.exports = {
publicPath: ‘/dist/‘
}

After running npm run build the paths to the js and css files now include the sub-directory

[Vue.js] View doesn't get updated after updates in store Vue js

there is Store, where there is actions and mutations

My action loadProducts calls the mutation setProducts, where I set values in state and it works fine

const actions = {
loadProducts({ commit }, accountId ) {
Products.where( { accountId: accountId } ).all().then((products) => {
commit(“setProducts”, {accountId: accountId, products: products.data})
});
},
}
const mutations = {
setProducts(state, {accountId, products}) {
Vue.set(state, ‘products’, products);
}
}

And then in my component I get the data, using mapGetters and computed

computed: {
…mapGetters([
‘products’
]),
products2() {
console.log(this.products)
return this.products;
}

Everything works, but then I try to update the data, it also works, I get updated state - in Vuex console I can see my updates state and new data, but the view itself won’t be updated - so there is to reload the page, to see the data appears.
I also do it via actions, mutations and getters, in mutations it looks like this:

replace() {
Vue.set(state, key, val);
}

Solution :

Should you be using mapState instead of mapGetters to directly map the state products to the component? Do you have a getter called products that does some extra work?

…mapState([
‘products’
]),

[Vue.js] How to toggle add remove multiple items in an array at the same position?

when using vuetify datatable. In that table when adding which table header and data has to show. I has written some code related to remove or add items in an array. But it is not proper code. If I remove multiple headers they are removing. But if I add them again their order changing. Can anyone please help me.

Please go through the below link for the code in codepen

A full code can be found in

https://codepen.io/kiranvilla/pen/JVRvwg?editors=1010

Solution :

You can do this by changing only the headers data when you apply the filter, and the table can be like this. You can add headers and data binding dynamically,

<v-data-table
:headers=”headers”
:items=”desserts”
class=”elevation-10”
\>
<template v-slot:items=”props”>
<td v-for=”(head, index) in headers” :key=”index”>
{ props.item[head[‘value’]] }
</td>
</template>
</v-data-table>

https://codepen.io/anon/pen/dLpaOp?editors=1010

[Vue.js] Vue.js Consuming API through Axios giving error Uncaught (in promise) TypeError Cannot read property 'protocol' of undefined

I tried to consuming api thorugh Axios in VueJS. But it giving error when i tried to fetch data. console log(res.data). Need the help. looks like i missed something

Uncaught (in promise) TypeError: Cannot read property ‘protocol’ of undefined

here’s the code in API.Js

import axios from ‘axios’;
import API from ‘../API’;

var urlLogin = API.url.host + ‘/login’;

var login = {
init: function(){
this.vueConfig();
if(localStorage.getItem(‘token’) != null){
window.location.replace(“./input-mobile.html”);
}
},
vueConfig: function(){
var app = new Vue({
el: ‘#app’,
data: {
isSubmit: false,
email: “email”,
password: “password”,
},
methods: {
submitLogin: function(){
this.isSubmit = true;
axios.post()
axios({
method: ‘post’,
url: urlLogin,
data: {
email: this.email,
password: this.password
}
}).then(res =>{
console.log(res.data);
this.isSubmit = false;
localStorage.setItem(“token”, res.data.access_token);
localStorage.setItem(“name”, res.data.fullname);
window.location.replace(“./input-mobile.html”);
}, err =>{
console.log(err);
this.isSubmit = false;
});
}
}
});
}
}

module.exports = login;

API is ok. in network (inspect) of browser api giving correct response. But it failed to fetch data

Solution :

You’re referencing the wrong object in the Axios callback. Try adding let self = this at the beginning of the submit method and then in the callback, change this.isSubmit by self.isSubmit.

submitLogin: function(){
let self = this;
this.isSubmit = true;
axios.post()
axios({
method: ‘post’,
url: urlLogin,
data: {
email: this.email,
password: this.password
}
}).then(res =>{
console.log(res.data);
self.isSubmit = false;
localStorage.setItem(“token”, res.data.access_token);
localStorage.setItem(“name”, res.data.fullname);
window.location.replace(“./input-mobile.html”);
}, err =>{
console.log(err);
self.isSubmit = false;
});
}

[Vue.js] How to align the contents to the center of the v-card component in Vuetify?

Currently in the products.vue, there is an array of productList containing 4 objects. I will loop through the array and pass each individual objects to the ProductsItem.vue.js component. In that component, I will create the cards using vuetify. However, when unable to align the contents to the centre of the card. Here are my code, a screenshot of my cards and the desired result

Products.vue

<template>
<div>
<h1>Products</h1>
<v-container class=”my-5”>
<v-layout row wrap>
<v-flex xs12 sm6 md4 v-for=”productItem in productList”
:key=”productItem.id”>
<ProductItems :productItem=”productItem”/>
</v-flex>
</v-layout>
</v-container>
</div>
</template>

<script>
import ProductItems from “@/components/ProductItems”;

export default {
data() {
return {
productList: [
{
id: 1,
name: “Superdry”,
description: “Rookie Aviator Patched Bomber”
},
{
id: 2,
name: “SuperHot”,
description: “Rookie Aviator Patched Bomber”
},
{
id: 3,
name: “Buron MensWear”,
description: “Skinny Fit Oxford Shirt In White”
},
{
id: 4,
name: “Asos”,
description: “slim shirt with stretch in blue”
}
]
};
},

components: {
ProductItems
}

ProductItem.vue

<template>
<v-card flat class=”ma-3 text-xs-center”>
<v-img src=”https://cdn.vuetifyjs.com/images/cards/desert.jpg" aspect-
ratio=”2.75”></v-img>
<v-card-title primary-title>
<div>
<h3 class=”headline pink–text text–accent-2”>
{productItem.name}</h3>
<div>{productItem.description}</div>
</div>
</v-card-title>
<v-card-actions>
<v-btn flat color=”orange”>Add to Cart</v-btn>
</v-card-actions>
</v-card>
</template>

<script>
export default {
props: [“productItem”],
data() {
return {};
}
};
</script>

Solution :

v-card-title and v-card-actions are flex components so by adding class=”justify-center” to both you can centralize the whole thing:

<v-card-title primary-title class=”justify-center”>
<div>
<h3 class=”headline pink–text text–accent-2>Superdry</h3>
<div>Rookie Aviator Patched BomberproductItem.description</div>
</div>
</v-card-title>
<v-card-actions class=”justify-center”>
<v-btn flat color=”orange”>Add to Cart</v-btn>
</v-card-actions>

I used the own example in the Codepen you provided.

Hope it helps :)