在推文中添加标记用户的链接(vuejs)

发布于 2025-01-26 01:59:42 字数 2046 浏览 0 评论 0原文

是否可以将链接添加到Twitter用户配置文件中,该链接在推文中标记了? 我想出了如何在文本中找到带有“ Inclast”的标记用户,但是我无法添加使用“ .link”或“ .href”属性的链接。

    axios.post(API_URL, null, { params }).then(res => {

        res.data.tweets.forEach(tweet => {
          const tweetData = {
            id: tweet.id,
            tweet_text: tweet.tweet_text,
            twitter_name: tweet.twitter_name,
            twitter_username: tweet.twitter_username,
            added_at: moment(String(tweet.added_at)).format('MM/DD/YYYY hh:mm'),
          }
          this.tweets.push(tweetData)
          this.tweets.forEach(el => {
            el.tweet_text.split(' ').forEach(word => {
              if (word.includes('@')) {

              }
            })
          })
        })
    })

这是显示数据的组件

        <div class="tweets-container">
          <div
            v-for="tweet in tweets"
            :key="tweet.id"
          >
            <div class="tweet-card">
              <div class="username-time">
                <div class="user-info">
                  <p class="name">
                    {{ tweet.twitter_name }}
                  </p>
                  <p class="user-info-p">
                    @
                  </p>
                  <p class="username">
                    <a
                      :href="'https://twitter.com/' + tweet.twitter_username"
                      class="twitter_link"
                      target="_blank"
                    >
                      {{ tweet.twitter_username }}
                    </a>
                  </p>
                </div>
                <div class="time">
                  <p>{{ tweet.added_at }}</p>
                </div>
              </div>
              <div class="text">
                <p>{{ tweet.tweet_text }}</p>
              </div>
            </div>
          </div>
        </div>

Is it possible to add a link to twitter user profile which is tagged in a tweet?
I figured out how do i find tagged users in a text with 'includes', but i am not able to add a link either with '.link' or '.href' attribbute.

    axios.post(API_URL, null, { params }).then(res => {

        res.data.tweets.forEach(tweet => {
          const tweetData = {
            id: tweet.id,
            tweet_text: tweet.tweet_text,
            twitter_name: tweet.twitter_name,
            twitter_username: tweet.twitter_username,
            added_at: moment(String(tweet.added_at)).format('MM/DD/YYYY hh:mm'),
          }
          this.tweets.push(tweetData)
          this.tweets.forEach(el => {
            el.tweet_text.split(' ').forEach(word => {
              if (word.includes('@')) {

              }
            })
          })
        })
    })

This is component where data is shown

        <div class="tweets-container">
          <div
            v-for="tweet in tweets"
            :key="tweet.id"
          >
            <div class="tweet-card">
              <div class="username-time">
                <div class="user-info">
                  <p class="name">
                    {{ tweet.twitter_name }}
                  </p>
                  <p class="user-info-p">
                    @
                  </p>
                  <p class="username">
                    <a
                      :href="'https://twitter.com/' + tweet.twitter_username"
                      class="twitter_link"
                      target="_blank"
                    >
                      {{ tweet.twitter_username }}
                    </a>
                  </p>
                </div>
                <div class="time">
                  <p>{{ tweet.added_at }}</p>
                </div>
              </div>
              <div class="text">
                <p>{{ tweet.tweet_text }}</p>
              </div>
            </div>
          </div>
        </div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文