[Vuejs]-Find a specific word in text, and add link(Vuejs)

0👍

I don’t think it’s going to work this way.

You should use a computed property which will append the username to the twitter base link. Then, in your template, you can link the href property to the computed property.

computed: {
    userLink: function () {
      return "http://twitter.com/" + this.tweet.twitter_username
    }
  }

You can now use this "userLink" directly in your template.

<p class="username">
  <a
    :href="userLink"
    class="twitter_link"
    target="_blank"
  >
   {{ tweet.twitter_username }}
   </a>
</p>

I didn’t test the code I wrote, feel free to let me know if you need further advice 😉

Leave a comment