if (success) { context.bookingData.city = context.city; context.bookingData.departureFlightDate = context.departureFlightDate; context.bookingData.arrivalFlightDate = context.arrivalFlightDate; context.bookingData.idParkingService = context.idParkingService; context.bookingData.Price = context.bookings.price.items.data.price; //const booking = JSON.stringify(context.bookingData); context.addBookingData(context.bookingData); context.$router.push({ path: "parkplatz-buchen-schritt-2", }); }cómo abrir esta ruta en una nueva ventana o pestaña al mismo tiempo tengo que pasar datos de contexto al destino
Para abrir la ruta en una nueva ventana
Inicio.vue
<template> <button v-on:click="openInNewWindow()">Open in new window</button> </template> <script> export default { methods: { openInNewWindow(){ let routeData = this.$router.resolve({ path: '/about', query: { city : 'test', departureFlightDate : 'test', arrivalFlightDate : 'test', idParkingService : 'test', price : 'test' } }); window.open(routeData.href, '_blank'); } } } </script>enrutador
import Home from '../views/Home.vue' import About from '../views/About.vue' const routes = [ { path: '/', name: 'Home', component: Home }, { path: '/about', name: 'About', component: About } ] const router = createRouter({ history: createWebHistory(process.env.BASE_URL), routes }) export default routerAcerca de.vue
<template> <div class="about"> <h1>This is an about page</h1> {{this.$route.query.city}} </div> </template> <script> export default { mounted(){ console.log(this.$route.query) } } </script>