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

165
Views
¿Cómo puedo enviar estos datos de configuración regional con accesorios en el enrutador VueJS?

Esta ruta debe ser localhost:8080/hotel/:id (id = json.hoteID)

Huevo: localhost:8080/hotel/101

y esta ruta debe mostrarme mis propios datos

Deberíamos usar VueJS vue-router

 import json from "@/assets/data/Hotels.json"; data() { return { data: json, }; },
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

this.$route.push({ params:{ id:this.data.hotelID } })
about 4 years ago · Juan Pablo Isaza Report

0

Puede obtener hotelID de $route.params docs y luego encontrar el hotel de datos necesario de Hotels.json por este $route.params.id . Manifestación

Hoteles.json

 { "hotels": [ { "id": 1, "name": "hotel 1" }, { "id": 2, "name": "hotel 2" }, { "id": 3, "name": "hotel 3" } ] }

enrutador.js

 const routes = [ { path: "/", name: "hotels", component: function () { return import("@/components/Hotels.vue"); } }, { path: "/hotel/:id", name: "hotel", component: function () { return import("@/views/Hotel.vue"); } } ];

aplicación.vue

 <template> <div id="app"> <div id="nav"> <router-link to="/">Hotels</router-link>| <template v-for="(item, key) in hotels"> <router-link :key="key" :to="`/hotel/${hotels[key].id}`">{{ hotels[key].name }}</router-link >| </template> </div> <router-view /> </div> </template> <script> import json from "./Hotels.json"; export default { name: "App", data() { return { hotels: json.hotels, }; }, }; </script>

hotel.vue

 <template> <div> <h1>{{ hotel.name }}</h1> </div> </template> <script> import json from "../Hotels.json"; export default { data() { return { hotels: json.hotels, }; }, computed: { hotel() { return this.hotels.find((item) => item.id === +this.$route.params.id); }, }, }; </script>
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!