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

104
Views
Checking for a number in the url
 if(window.location.href.includes('part_category_tags[]=2')) {
   this.checkedCategories.push(2);
 }

Needed: depending on what the number is next to the part_category_tags[]= parameter, push this number into the array. also, it may be that such a parameter occurs twice like (Or not be at all):

&part_category_tags[]=3&part_category_tags[]=2

Without vue-router

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can just loop through the params.

const url = new URL('https://fake.domain.name/?fake=query&part_category_tags[]=3&part_category_tags[]=2'); // document.location instead of fake utl.

let params = url.searchParams;

params.forEach((v,q) => console.info(q, v)); // just output queries and values

params.forEach((v,q) => { if (q === 'part_category_tags[]' && v === '2') { console.info('Pushing the 2') } });
// params.forEach((v,q) => { if (q === 'part_category_tags[]' && v === '2') { this.checkedCategories.push(v); } });

Updated with numberless code.

// // use document.location instead of fake url.
const url = new URL('https://fake.domain.name/?fake=query&part_category_tags=3&part_category_tags=2');

let params = url.searchParams;

params.forEach((v,q) => { if (q === 'part_category_tags') { console.info(`Pushing the ${v}`) } });
// params.forEach((v,q) => { if (q === 'part_category_tags') { this.checkedCategories.push(v); } });

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!