I receive some text from server which may contain some hashtags and when displaying this text I would like to convert these tags with links.
Example text is: "Today #weather is very nice"
Following code converts the string to
Today <router-link to="/tag/weather">#weather</router-link> is very nice
but it is not rendered again to <a>
tag.
<template>
<p v-html="content"/>
</template>
<script>
export default {
methods: {
convertHashTags: function(str) {
return str.replace(/#([\w]+)/g,'<router-link to="/tag/$1">#$1</router-link>')
}
},
data() {
return{
content: 'Today #weather is very nice'
};
}
</script>
How can I re-render content?
I tried https://codepen.io/movii/pen/WORoyg this approach but it expects whole string to be a single link not some text and some links.