Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
¿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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!