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

160
Views
nombre de ruta coincidente en el enrutador personalizado

Estoy creando un enrutador personalizado donde quiero hacer coincidir el nombre de la ruta con un componente web específico.

 public Router = new Router([ new Route('/dev/', 'my-element'), new Route('/dev/other', 'other-view') ], "#application_page");

Podría haber otros nombres de página como /dev/page/1 , por lo que debo asegurarme de que sea lo más sólido posible.

Mi primer enfoque es demasiado básico:

 const pathname = window.location.pathname; console.log(pathname); for (let i = 0; i < this.routes.length; i++) { if (pathname.indexOf(this.routes[i].url) >= 0) { console.log(this.routes[i].url); const el = renderRoot.querySelector(this.containerId); if (el != null) { el.appendChild(this.routes[i].component); return; } } }

¿Cuál es la mejor manera de encontrar la ruta correcta?

about 4 years ago · Juan Pablo Isaza
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!