Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

225
Vistas
¿Cómo obtener los parámetros de consulta para la llamada axios en Vuejs?

HolaMundo.vue

 import axios from "axios"; export const deploymentattribute = ({ serv, id }) => axios.get( api cal here ................. );
 <template> <div> <div v-for="(attribute, index) in attributes" :key="index"> {{ attribute.att }} </div> </div> </template> <script> import { deploymentattribute } from "./deploymentattribute"; export default { name: "DeploymentAttributeView", data() { return { attributes: [], }; }, async mounted() { const response = await deploymentattribute({ servicetype: this.$route.query.ser, id: this.$route.query.id, }); this.attributes = response.data; }, }; </script>

Problema con el código anterior, no puedo obtener los parámetros de cadena de consulta dinámicamente. Obtener como undefined

¿Hay alguna forma de pasarlos dinámicamente?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Deberías

 import axios from "axios"; export const deploymentattribute = ({ servicetype, id }) => axios.get( `http://10.11.12.13:3000/servicedetail/?servicetype=${servicetype}&id=${id}` );

y

 <template> <div> <div v-for="(attribute, index) in attributes" :key="index"> {{ attribute.attribute }} {{ attribute.value }} </div> </div> </template> <script> import { deploymentattribute } from './deploymentattribute' export default { name: "DeploymentAttributeView", data() { return { attributes: [], }; }, async mounted() { const response = await deploymentattribute({ servicetype: this.$route.query.servicetype, id: this.$route.query.id }) this.attributes = response.data }, }; </script>

Porque no tiene this contexto por defecto en un archivo js .

about 4 years ago · Juan Pablo Isaza Denunciar

0

Obtenga la identificación de parámetros ya sea por:

 let urlParams = new URLSearchParams(window.location.search); const id = urlParams.id;

o

 const id = this.$route.query.id;

Luego, en lugar de comillas, use la plantilla literal para usar el valor variable dentro de una cadena:

 export const deploymentattribute = ({ servicetype, id }) => axios.get(`http://example.com/servicedetail/?servicetype=. {servicetype}&id=${id}`); );
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda