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

204
Views
¿Cómo uso vue.js mixin en reaccionar?

A diario uso vue.js, pero ahora mismo estoy trabajando en un proyecto de reacción. Tengo este método de traducción:

 function __(key, replace = null) { let translation, translationNotFound = true; try { translation = key.split('.').reduce((t, i) => t[i] || null, window._translations[window._locale].php); if (translation) { translationNotFound = false; } } catch (e) { translation = key; } if (translationNotFound) { translation = window._translations[window._locale]['json'][key] ? window._translations[window._locale]['json'][key] : key; } if (replace) { replace.forEach((value, key) => { translation = translation.replace(':' + key, value); }); } return translation; }

En vue, estoy usando un mixin para esto, por lo que se puede usar en todas partes. ¿Cómo puedo asegurarme de que puedo usar este método en mis componentes de reacción?

Ya hay muchos artículos rojos en línea, pero no puedo entenderlo.

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

0

Solo exporta tu función

 const myFunction = (key, replace = null) => { let translation, translationNotFound = true; try { translation = key.split('.').reduce((t, i) => t[i] || null, window._translations[window._locale].php); if (translation) { translationNotFound = false; } } catch (e) { translation = key; } if (translationNotFound) { translation = window._translations[window._locale]['json'][key] ? window._translations[window._locale]['json'][key] : key; } if (replace) { replace.forEach((value, key) => { translation = translation.replace(':' + key, value); }); } return translation; } export default myFunction;

Cuando quieras importar

 import myFunction from 'path/to/the/file'
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!