vue.js – Agregar una vista dinamica a mi proyecto de vue

tengo router configurado asi:

const routes = (
  {
    path: '/',
    name: 'Inicio',
    component: VistaInicio
  },
   {
    path: '/busqueda-listado',
    name: 'Búsqueda Listado',
    component: VistaBusquedaListado
  },
  {
    path: '/busqueda-listado/?ver-prop=:id',
    name: 'Propiedad Desde Url',
    component: PropiedadURL
  },
 

Los dos primeros funcionan bien, ahora, yo quiero el siguiente comportamiento:

Quiero que, al entrar por URL y encontrarme la variable ?ver-prop=:id' quiero mostrar la vista PropiedadURL, en cambio si no está dicha variable quiero mostrar VistaBusquedaListado (esta segunda vista ya funciona)

En mi vista para ver-prop=:id (PropiedadURL) tengo este componente, que no logro visualizar

<template>Soy la vista desde url
   {{ $route.params.id }}
</template>

<script>
  export default {
    setup(props) {
      return {};
    },
  };
</script>

Me está pasando que si entro a http://localhost:8080/busqueda-listado/?ver-prop=3591507 sigo viendo la vista de VistaBusquedaListado.

(Incluso quisiera hacer algo un poco mas complejo, quisiera que si encuentro esta url, y ademas tengo una cierta variable true en la store, mostrar PropiedadURL, de lo contrario mostrar VistaBusquedaListado. Pero como sin chequear la store, la vista no me anda, quisiera empezar por el principio.)

magento2 – Magento 2 Vue storefront [search] Can not connect the vue-storefront-api / ElasticSearch instance!

magento2 – Magento 2 Vue storefront (search) Can not connect the vue-storefront-api / ElasticSearch instance! – Magento Stack Exchange

vue.js – Como navegar com rotas vue em projetos sem CLI, ou seja, entre arquivos HTML?

Preciso ir de um artigo de blog, clicado na index.html, até a blog_post.html mostrando o artigo escolhido pelo usuário. Isto, em um mesmo arquivo ok. O problema é a navegação entre arquivos html.

<router-link to="/blog-post.html/post-component/ + noticia.id">{{ noticia.blogBtn }}</router-link>

vue.js – ¿Como muestro imagen o Video dependiendo de la extension? Laravel + Vue

tengo un problema que no logro resolver, estoy tratando de validar si lo que estoy pasando es una imagen o un video a través de la extension, al principio no me muestra la imagen, pero cuando hago click en el devtools de vuejs me sale dicha imagen que se subio, alguien sabe el motivo de dicho resultado, quiero es lograr que se muestra la imagen o el video dependiendo del recurso que se vaya a pasar. Dejo codigo:

<template>
    <div class="card" :style="cssVars">
        <template v-if="extension == 'jpg' || extension == 'png' || extension == 'jpeg' ">
               <img :src="https://es.stackoverflow.com/url" alt="" class="card-img-top">
        </template>
         <template v-if="extension == 'avi' || extension == 'mp4'">
               <div class="embed-responsive embed-responsive-16by9">
                    <iframe class="embed-responsive-item" :src="https://es.stackoverflow.com/url" allowfullscreen></iframe>
                </div>
        </template>
    </div>
</template>
<script>
export default {
    props: ('width', 'color', 'height', 'media'),
    data(){
        return{
            url:'',
            extension: ''
        }
    },
    computed:{
        cssVars(){
            return{
                '--color': this.color,
                '--width': this.width,
                '--height': this.height
            }
        },
        link(){
            this.extension = this.media.split('.').pop()
            return this.url = this.media
        }
    },
 
}
</script>
<style scoped>
    .card{
        background-color: var(--color);
        width:var(--width);
        height: var(--height);
        border-radius: 10px;
    }
</style>

“`

introducir la descripción de la imagen aquí
introducir la descripción de la imagen aquí

Vue

If you’re a newcomer to the programming field, the odds are may possibly not you are aware of Vue. That can be in comparison to Angular as well as gallop. But it won’t signify it is maybe not so great in any way. The frame has just one of those fastest-growing libraries among the rest of the frameworks. The main reason behind its success is its own high speed and basic coding. Much like answers, you may use extra packages to secure up or scale your programs.

javascript – Is there a way to pass a reactive variable in a method call in vue?

i want it so that i can call a variable and manipulate it in the method like this,

<template>
<div>
<a @click=change(hair,'red')>Red</a>
<a @click=change(hair,'blue')>Blue</a>
<a @click=change(eyes,'yellow')>Yellow</a>
</div>
</template>


data() {
  return {
    eyes: '',
    hair: ''
  }
}

methods: {
   change(model, type){
     model = type
     ... someother actions
   }
}

when i call the change function it receives a model and a text and then i can manipulate it on the methods area

vue.js – Vue form validation

I’m learning Vue and I would like an opinion to improve the form validation that I have implemented. This is my component:

<template>
    <section class="p-0 d-flex align-items-center">
        <div class="container-fluid">
        <div class="row">

            <!-- Right START -->
            <div class="col-md-12 col-lg-8 col-xl-9 mx-auto my-5 position-relative">
            <!-- Shape Decoration START -->
            <!-- Shape 1 -->

            <!-- Shape Decoration END -->
            <div class="row h-100">
                <div
                class="
                    col-md-12 col-lg-10 col-xl-5
                    text-start
                    mx-auto
                    d-flex
                    align-items-center
                "
                >
                <div class="w-100">
                    <h3>Sign up for your account!</h3>
                    <p>
                    Join us today! Create your account easily with less
                    information.
                    </p>
                    <!-- Form START -->
                    <form class="mt-4" @submit.prevent="submit">
                    <!-- Email -->
                    <div class="mb-3">
                        <label class="form-label" for="email">Email address</label>
                        <input
                        v-model="data.name"
                        v-bind:class="{ 'is-invalid': emailFailure }"
                        required
                        type="email"
                        class="form-control"
                        id="email"
                        aria-describedby="emailHelp"
                        placeholder="E-mail"
                        />
                        <div class="invalid-feedback">
                        {{ emailFailureText }}
                        </div>
                        <small id="emailHelp" class="form-text text-muted"
                        >We'll never share your email with anyone else.</small
                        >
                    </div>
                    <!-- Username -->
                    <div class="mb-3">
                        <label class="form-label" for="email">Username</label>
                        <input
                        v-model="data.username"
                        v-bind:class="{ 'is-invalid': usernameFailure }"
                        required
                        type="text"
                        class="form-control"
                        id="username"
                        placeholder="Username"
                        />
                        <div class="invalid-feedback">
                        {{ usernameFailureText }}
                        </div>
                    </div>
                    <!-- Password -->
                    <div class="mb-3">
                        <label class="form-label" for="password">Password</label>
                        <input
                        v-model="data.password"
                        v-bind:class="{ 'is-invalid': passwordFailure }"
                        required
                        type="password"
                        class="form-control"
                        id="password"
                        placeholder="*********"
                        />
                        <div class="invalid-feedback">
                        {{ passwordFailureText }}
                        </div>
                    </div>
                    <!-- Password -->
                    <div class="mb-3">
                        <label class="form-label" for="password2"
                        >Confirm Password</label
                        >
                        <input
                        v-model="data.password2"
                        v-bind:class="{ 'is-invalid': password2Failure }"
                        type="password"
                        class="form-control"
                        id="password2"
                        placeholder="*********"
                        />
                        <div class="invalid-feedback">
                        {{ password2FailureText }}
                        </div>
                    </div>
                    </form>
                    <!-- Form END -->
                    <div class="bg-dark-overlay-dotted py-2 my-4"></div>
                </div>
                </div>
            </div>
            </div>
            <!-- Right END -->
        </div>
        </div>
    </section>
    </template>

    <script lang="ts">
    import { defineComponent, reactive, ref } from "vue";
    import { useRouter } from "vue-router";

    export default defineComponent({
    name: "Register",
    setup(props) {
        const data = reactive({
        username: "",
        email: "",
        password: "",
        password2: "",
        });
        const router = useRouter();

        const emailFailure = ref(false);
        const emailFailureText = ref("");
        const usernameFailure = ref(false);
        const usernameFailureText = ref("");
        const passwordFailure = ref(false);
        const passwordFailureText = ref("");
        const password2Failure = ref(false);
        const password2FailureText = ref("");

        const submit = async () => {
        emailFailure.value = false;
        emailFailureText.value = "";
        usernameFailure.value = false;
        usernameFailureText.value = "";
        passwordFailure.value = false;
        passwordFailureText.value = "";
        password2Failure.value = false;
        password2FailureText.value = "";

        const res = await fetch(`${process.env.VUE_APP_API_URL}/auth/register`, {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify(data),
        });

        if (!res.ok) {
            const errors = await res.json();
            emailFailure.value = true;
            emailFailureText.value = "the email is invalid";
        }

        /*
        if (res.text === 200) {
            await router.push("/login");
        }*/
        };

        return {
        data,
        emailFailure,
        emailFailureText,
        submit,
        };
    },
    });
</script>

what I did so far is define inside the method setup, a data variable which will handle all the values that the user fill in the form. These values are passed to my API using the fetch method which is called in the submit function.

When the API call is completed, I check if the response was successfull or not by checking the ok property. If the response is unsuccessful I valorize all the property of each field manually to display the error on the proper field.

The code above just have the emailFailure implementation, and this is actually working fine, but my concern is about all the fields. Suppose that I have 20 fields, should I have create 20 property which handle the error, and other 20 which handle the error message?

There is a way to handle multiple fields without create all those properties?

Also, the API response return an array of objects like this:

({
    location: "body",
    msg: "invalid email",
    param: "email",
    value: ""
}, {
    location: "body",
    msg: "Password must be at least 8 characters",
    param: "password",
    value: ""
})

as you can see I have the param field which is equal to the input name defined in the Vue component.

vue.js – VUE, tabla con multiples V-Select

estoy creando una tabla en VUE generada dinamicamente de unos datos pasados con JSON, dentro de la tabla modifico un campo para que se pueda escoger entre unas opciones.

Cuando se selecciona ejecuta una función, hasta aquí todo correcto.

El problema es visual, cuando hago la selección en uno de los Selects, todos los otros cogen el mismo valor, solo es visual, no ejecutan la función.

<v-data-table
            :headers="headers"
            :items="liniesCam"
            :items-per-page="20"
            :search="search"
            class="elevation-1"
            :loading="myloadingvariable" 
            loading-text="Cargando los datos... espera por favor"
        >

        <template v-slot:(`item.diesPerRepartir`)="{ item }">
          <v-select v-if="item.diesPerRepartir.length > 1 "
            :items="item.diesPerRepartir"
            label="Fecha de planificación"
            v-model = "dataRep"
            :id = "item.zt"
            :name = "item.zt"
            @change="guardarData(item.idLinia, item.merma)"
          ></v-select>
          <p v-else>{{ item.diaReparto}}</p>
        </template>

Formulario al cargar la pagina

Tabla creada

Seleccion en la primera fila

(introducir la descripción de la imagen aquí)(2

Las tres filas cambian el contenido

introducir la descripción de la imagen aquí

vue.js – How Do I Properly Initialize RxDB in a Vue App with global

I’m trying out RxDB for the first time in a Vue 3 app, and getting started is a bit more tricky than I expected (and it’s probably my fault).

I installed RxDB with NPM in my project ("rxdb": "^9.20.0"), then I did this in my main.js file:

import { createRxDatabase, RxDatabase } from 'rxdb'
 
const db = await createRxDatabase({
  name: 'MyApp', adapter: 'idb'
})

console.dir(db)

I then get this error:

Uncaught ReferenceError: global is not defined

So I check the docs and found this that I need a global polyfill like this:

(window as any).global = window;
(window as any).process = {
    env: { DEBUG: undefined },
};

That looks to be an example using Typescript from Angular. When I try it in Vue, I then get this error:

Invalid assignment target
3  |  import { createRxDatabase, RxDatabase } from 'rxdb'
4  |  
5  |  const db = await createRxDatabase({
   |             ^
6  |    name: 'Avid', adapter: 'idb'
7  |  })

10 minutes in and I’m already a mess. 😅 Can someone show me how to properly start up RxDB in a Vue app?

javascript – VUE 3 error: An attempt was made to use an object that is not, or is no longer, usable

I have an Vue 3 app:

const vm = createApp({
  data () {
    return {
      obj: null,
      kategorije: kategorije
    }
  },
  async created () {
    const response = await fetch(api + '?nekretnine')
    this.obj = await response.json()
  },
  methods: {
    del: function (id) {
      fetch(api + '?delete=' + id, fetchOptDELETE)
        .then(response => {
          if (response.ok) {
            return response.json()
          } else {
            throw new Error('NETWORK RESPONSE ERROR')
          }
        })
        .then(data => {
          $('(data-iditem="' + id + '")').fadeOut('slow')
          if (data == true) {
            toastText.innerHTML = 'Radnja uspješna!'
            toastList.forEach(toast => toast.show())
          } else {
            toastText.innerHTML = 'Greška!' + data
            toastList.forEach(toast => toast.show())
          }
        })
    },
    edit: function (id) {
      let item = this.$data.obj.filter(e => e.nek_id == id)
      naziv.value = item(0).nek_naslov
      cijena.value = item(0).nek_cijena
      kat.selectedIndex = item(0).kat_id
      console.log(item(0).nek_img)
      console.log(fileEl)
      console.log(fileEl.value)
      fileEl.value = item(0).nek_img
      $('#exampleModal2 .modal-title').attr('data-nekid', id)
      $('#exampleModal2 .modal-title').text('EDITIRAJ NEKRETNINU')
      $('#exampleModal2').modal('show')
    },
    refresh (data) {
      Object.assign(this.$data.obj, data) // <--
    }
  },
  template: `<div class="card" v-bind:data-id="item.kat_id" v-bind:data-iditem="item.nek_id" style="width: 18rem;" v-for="item in obj" :key="item.nek_id">
  <img v-bind:src="https://stackoverflow.com/item.nek_img" class="card-img-top" alt="...">
  <div class="card-body" >
    <h5 class="card-title">{{ item.nek_naslov }}</h5>
    <p class="card-text">Cijena: {{ item.nek_cijena }}</p>
    <div class="ico">
      <i v-on:click="edit(item.nek_id)" class="bi bi-pencil-square"></i>
      <i v-on:click="del(item.nek_id)" class="bi bi-trash-fill"></i>
    </div>
  </div>
</div>`
}).mount('#app')

Problem is at line inside edit: function (id) method:

  fileEl.value = item(0).nek_img

With error:

Uncaught DOMException: An attempt was made to use an object that is not, or is no longer, usable

And I simply don’t understand why, because when I use line before it I get all correct values:

  console.log(item(0).nek_img)
  console.log(fileEl)
  console.log(fileEl.value)

results in:

../src/img/huf house.jpg 
<input id="file" type="file" name="file">
<empty string>

It should just set file input value to ../src/img/huf house.jpg

Any help is appreciated.

DreamProxies - Cheapest USA Elite Private Proxies 100 Cheapest USA Private Proxies Buy 200 Cheap USA Private Proxies 400 Best Private Proxies Cheap 1000 USA Private Proxies 2000 USA Private Proxies 5000 Cheap USA Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive.com Proxies-free.com New Proxy Lists Every Day Proxies123.com Proxyti.com Buy Quality Private Proxies