Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

278
Vistas
Cannot import file based on user input

I have small vue.js app.

I want to import specific json based on user input.

import content from "@/posts/posts/" + new URL(location.href).searchParams.get('id') + ".json";

Every time I do this I get an error on the first plus sign.

Module parse failed: Unexpected token (7:37)
File was processed with these loaders:
 * ./node_modules/vue-loader/dist/index.js
You may need an additional loader to handle the result of these loaders.
> import content from "@/posts/posts/" + new URL(location.href).searchParams.get('id') + ".json"

But when I try to import it with one string like this:

import content from "@/posts/posts/0.json";

it works.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try dynamic imports refer to this article alternatively, you could also use require instead of import but not sure which one is recommended.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda