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

294
Views
reload=true no funciona en la función @click

Estaba trabajando en el cambio de moneda. Llamo al método al hacer clic en el enlace y después de que el método sea exitoso quiero que se vuelva a cargar. pero recargar no funciona en absoluto. la moneda se almacena en la cookie, si actualizo la página manualmente, también se actualiza en la barra de navegación, pero quiero que se vuelva a cargar automáticamente una vez que se complete el método.

aquí está el código en la barra de navegación ...

 <b-dropdown position="is-bottom-left" aria-role="menu"> <template #trigger> <a class="navbar-item font-bold" role="button"> {{currency}} <b-icon icon="menu-down"></b-icon> </a> </template> <b-dropdown-item v-for="(item, index) in currencies" :key="index" has-link aria-role="menuitem"> <a class="no-underline" @click="setCurrency(item.iso, (reload = true))"><span class="text-pink-600 font-bold">{{item.fullname}} ({{item.iso}})</span></a> </b-dropdown-item> </b-dropdown>

este es el método.

 methods: { setCurrency(newcurrency) { this.$cookies.set(`usercurrency`, newcurrency, { path: '/', maxAge: 60 * 60 * 24 * 7 }) // window.location.href = '/' } }

Pensé en usar window.location.href = '/' después de configurar la cookie, pero no puedo hacerlo porque estoy usando el mismo método en el gancho creado como el siguiente código para configurar la moneda según el país del usuario y dirá ventana no definida .

 created() { const isCurrency = this.$cookies.get('usercurrency') const isUserCountry = this.$cookies.get('usercountry') if (isCurrency === undefined) { if (isUserCountry === undefined) { fetch('https://ipinfo.io/json?token=*********') .then((response) => response.json()) .then((jsonResponse) => { const country = jsonResponse.country this.$cookies.set(`usercountry`, country, { path: '/', maxAge: 60 * 60 * 24 * 7, }) var CurrencyParam switch (country) { case 'IN': case 'NP': CurrencyParam = 'INR' break case 'US': CurrencyParam = 'USD' break case 'AU': CurrencyParam = 'AUD' break case 'CA': CurrencyParam = 'CAD' break case 'GB': CurrencyParam = 'GBP' break case 'AE': CurrencyParam = 'AED' break case 'RU': CurrencyParam = 'RUB' break case 'JP': CurrencyParam = 'JPY' break case 'SG': CurrencyParam = 'SGD' break case 'FR': case 'FI': case 'DE': case 'GR': case 'HU': case 'IT': case 'LT': case 'MT': case 'NL': case 'NO': case 'PL': case 'PT': case 'RO': case 'RS': case 'ES': case 'SE': case 'CH': case 'UA': CurrencyParam = 'EUR' break default: CurrencyParam = 'USD' } this.setCurrency(CurrencyParam) }) .catch((error) => { console.log(error) this.setCurrency('USD') }) } } },
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

La solución rápida podría ser pasar la reload como parámetro opcional a setCurrency

 methods: { setCurrency(newcurrency, reload) { this.$cookies.set(`usercurrency`, newcurrency, { path: '/', maxAge: 60 * 60 * 24 * 7 }) if (reload) window.location.href = '/' } }
over 4 years ago · Santiago Trujillo 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!