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

202
Views
Haciendo enlaces en el texto de un div clicable

Estoy tratando de hacer que las URL en un texto se pueda hacer clic con Nuxt/Vue.

El texto de entrada es: Learning Outside the Box - https://learningoutsidethebox.com

Tengo un método que lo convierte en un enlace:

 setLinks(text) { var Rexp = /(\b(https?|ftp|file):\/\/([-A-Z0-9+&@#%?=~_|!:,.;]*)([-A-Z0-9+&@#%?\/=~_|!:,.;]*)[-A-Z0-9+&@#\/%=~_|])/ig; return text.replace(Rexp, "<NuxtLink to='$1' target='_blank'>$1</NuxtLink>"); }

Después de eso, obtengo un resultado: Learning Outside the Box - <NuxtLink to='https://learningoutsidethebox.com' target='_blank'>https://learningoutsidethebox.com</NuxtLink> . Pero todavía no se puede hacer clic.

Cambiar a <a> no resolvió el problema.

¿Podría aclararme qué debo hacer para que este texto se convierta en un enlace que funcione?

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

0

Puedes probar con a etiqueta y v-html :

 new Vue({ el: '#demo', data() { return { url: 'Learning Outside the Box - https://learningoutsidethebox.com' } }, computed: { getLink() { return this.setLinks(this.url) } }, methods: { setLinks(text) { const Rexp = /(\b(https?|ftp|file):\/\/([-A-Z0-9+&@#%?=~_|!:,.;]*)([-A-Z0-9+&@#%?\/=~_|!:,.;]*)[-A-Z0-9+&@#\/%=~_|])/ig; return text.replace(Rexp, "<a href='$1' target='_blank'>$1</a>"); } } }) Vue.config.productionTip = false Vue.config.devtools = false
 <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <div id="demo"> <div v-html="getLink"></div> </div>

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!