Getting the parameters of a path from the URL's breadcrumb in Vue.js

Currently utilizing Vue

Attempting to include path parameters in breadcrumb URLs for my app's router.

Looking to achieve something similar to the following:

  {
      path: 'pages/gestion/region/:reg',
      name: 'gestion-depa',
      component: () => import('@/views/pages/MyPage.vue'),
      meta: {
        breadcrumb: [
          { title: 'Home', url: '/' },
          { title: 'region', active: true, url:"/pages/list/:reg" },//Having trouble using get parameters here 
          { title: 'dep', active: false }
        ],
        pageTitle: 'Gestion',
        rule: 'editor',
        requiresAuth: true,
      }
    },

The breadcrumbs currently redirect to /pages/list/:reg, but I need them to be dynamic like /pages/list/5

Any suggestions on how to achieve this would be greatly appreciated.

Thank you.

Answer №1

To easily modify the meta, consider utilizing beforeEnter:

meta: {
...
},
beforeEnter: (to, from, next) => {
  to.meta.breadcrumb[1].url = `/pages/detail/${to.params.id}`
  next();
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Comparing Pinia and useState() in Nuxt 3

Choosing Between Store (Pinia) and UseState When it comes to deciding between useState and a store like Pinia, the question arises - can useState replace any store such as Pinia? With useState allowing ref sharing across all components, determining whethe ...

"Integrating Phylotree.js into your Nuxt project: A step-by-step

After installing phylotreejs with the command npm install --save phylotree, I encountered an issue when trying to import it into my page as shown below: import * as d3 from 'd3'; import phylotree from 'phylotree/build/phylotree'; This ...

The ReactJS component is unable to resolve the specified domain name

Whenever I utilize a component like const React = require('react'); const dns = require('dns'); class DnsResolver extends React.Component { componentDidMount() { dns.resolve('https://www.google.com', (err, addres ...

Display a pop-up window upon clicking anywhere on the webpage using jQuery and HTML

Is it possible for me to create a pop-up window that opens a specific website when a user clicks anywhere on the page, similar to pop-up companies? Can this be achieved using HTML, JavaScript, and jQuery? Any help would be greatly appreciated. ...

Unable to disable background color for droppable element

For my project, I am working with two div boxes. My goal is to make it so that when I drag and drop box002 into another div box001, the background color of box001 should change to none. I have attempted to achieve this functionality using jQuery without s ...

Adding JSON data to an array with a click - a step-by-step guide

As I dive into working with React and integrating API JSON data into my project, I've encountered a small hurdle. I've implemented a function that allows users to enter a search query, resulting in a list of devices associated with their input be ...

Best practices for utilizing a Vue component multiple times on a single page

I am currently working on developing a user-friendly 24-hour time input that can be utilized seamlessly across various web browsers. In the past, I have leveraged Vue.js to create components that are employed singularly on a page by attaching them to an I ...

Prevent clicking on the <div> element for a duration of 200 milliseconds

I need to make this box move up and down, but prevent users from clicking it rapidly multiple times to watch it go up and down too quickly. How can I add a 200 millisecond delay on the click or disable clicking for that duration? View the jsfiddle example ...

What is the recommended data type to assign to the `CardElement` when using the `@stripe/react-stripe-js` package in TypeScript?

I'm struggling to determine the correct type to use for this import: import { CardElement } from '@stripe/react-stripe-js'; I have successfully used the types Stripe, StripeElements, and CreateTokenCardData for the stripe and elements props ...

Results don't align with search parameters

const searchClientes = (event) => { if (event.target.value === '') { getClientes(); return; } else { const searchTerm = event.target.value; const filteredClients = clientes.filter(cliente => { return cliente.nome ...

Enumeration field with Conditional logic

I am currently developing a Content Management System (CMS) using strapi for a client, and I want to provide them with the ability to control the questions included in a questionnaire. Each question will be categorized under different sections in the quest ...

Automatically appending textarea value in HTML tag upon form submission via JQuery

When a form is submitted through JQuery, the HTML tag automatically adds textarea value. This is my JQuery code: $('#calling').click(function() { $('#myform').submit(); }); Within my form, there is a textarea element: <textar ...

Unlock the potential of vue-datepicker by harnessing the power of multiple calendars

Currently, I am implementing the Composition API and utilizing the Vuepic/vue-datepicker library. However, I have encountered an issue with my datepicker setup. The code for my datepicker is as follows: <Datepicker multi-calendars multi-calendars-so ...

The setCountry function fails to properly change the country value

My goal is to establish a default country selection in checkbox options, I have three choices: United States, United Kingdom, and Rest of the world; Here's the constant called AVAILABLE_COUNTRIES which contains the iso codes for the mentioned countrie ...

Additional GET request made after update request

After the user updates their contact information in the frontend application, the state is updated and a PUT API request is made to update the current information. When updating user contact details with a PUT call, should another GET call be made to retr ...

Is there a way to prevent on-click errors in ReactJS that someone can share with me?

The onclick listener was expected to be a function, but instead received a value of string type. getListener@http://localhost:3000/static/js/bundle.js:18256:15 accumulateSinglePhaseListeners@http://localhost:3000/static/js/bundle.js:22846:39 <button on ...

What is the proper way to retrieve the value of the key "order" from this JSON object (containing semicolons in the name)?

Vijay Anand inquired about this particular matter yesterday, unfortunately, the discussion was closed before receiving any solutions: HTTP Response: { "entry": { "@xml:base": "https://API_PROC_SRV/", "@xmlns": "http://www.w3.org/2005/Atom", ...

Ways to bypass HostListener in Angular 2

In the process of developing a page with animations triggered on scroll, I encountered the challenge of ensuring that the animations only occur when the corresponding element is visible on the viewport. Utilizing Angular2 for this task led me to investigat ...

What steps can I take to ensure that the v-main element occupies at least 70% of the viewport height in Vuetify?

As a newcomer to Vuetify, I am still learning the ropes. One thing I've noticed is that <v-main> automatically expands to fill the space between <v-app-bar> and <v-footer>, taking up the entire viewport height. My concern arises wh ...

Leveraging Angular CLI in conjunction with the newest AspNetCore Angular 4 Single Page Application template

I'm currently experimenting with using Angular CLI alongside the latest JavaScriptServices AspNetCore Angular Spa template. In the past, I would simply copy and paste a .angular-cli.json file into my project's root directory, change "root" to "C ...