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

277
Views
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 answers
Answer question

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 Report
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!