I retrieve content from a CMS system (WordPress). In the "page.content" variable, links are outputted like so: <a href="#">
. How can I replace this content with: <nuxt-link to="#">
on the client side?
The question has been asked before, but no real answers: https://github.com/nuxt/nuxt.js/issues/2912 - despite this must be a pretty regular usecase.
Simple string replacement should suffice.
const string = 'links are outputted like so: <a href="#">. How can I replace this content with: <nuxt-link to="#">' const converted = string.replace(/<a/g, '<nuxt-link').replace(/href=/g, 'to='); console.log(converted)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.