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

271
Views
El archivo JS externo no funciona después de cargar VUE por primera vez

Estoy tratando de crear una aplicación de una sola página usando Vue + inercia + laravel . Tengo una plantilla html que incluye un archivo js externo . Al integrar la plantilla con vue, observo que js solo se ejecuta una vez después de que la página se actualice y no se aplique a la otra página (cuando navegue usando el enlace del enrutador)

Probé algún método:

A. agregue el script js dentro de la plantilla vue usando montado

 mounted() { let appscript = document.createElement("script"); appscript.setAttribute( "src", "/dist/js/app.js" ); document.head.appendChild(appscript); }

B. Agregue el script js usando metainformación

 metaInfo: { script: [ { src: "/dist/js/app.js", async: true, defer: true, }, ], },

aquí está mi archivo blade

 <!DOCTYPE html> <html lang="en" class="light"> <head> <meta charset="utf-8"> <link href="/dist/images/logo.svg" rel="shortcut icon"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title> CollaborApps </title> <link rel="stylesheet" href="{{ asset('dist/css/app.css') }}" /> <link href="{{ asset('css/app.css') }}" rel="stylesheet"> <script type="application/javascript" src="{{ asset('/js/app.js') }}" defer></script> <script type="application/javascript" src="{{ asset('/dist/js/app.js') }}" defer></script> <- this is the external js @routes </head> <body class="main"> @inertia </body> </html>

¿Cómo integrar el archivo javascript con vue SPA?

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!