0

Hello I have this property: text, and it contains a url but as plain text. I want to convert the url so it will be clickable.

<template>
    <div>
        <button class="fas fa-angle-down jwsingle__player__text__toggle" @click="toggle" :class="{ 'jwsingle__player__text__toggle--active': isOpen }">
        </button>
        <div v-show="isOpen" class="jwsingle__player__text__description">
            {{ text }}
        </div>
    </div>
</template>
<script>    
    export default {
        name: 'jwplayer-text-toggle',
        props: {
            text: {
                type: String,
            },
        },
        data() {
            return {
                isOpen: false,
            }
        },
        methods: {
            toggle() {
                this.isOpen = !this.isOpen;
            }
        }
    }
</script>
3
  • 1
    You need an <a :src="text">click me</a> tag. You should probably consider renaming "text" to "url" if it's always a URL Commented Feb 3, 2021 at 21:02
  • @maxshuty You mean <a :href="text"> :) Commented Feb 4, 2021 at 4:24
  • @tony19 doh, yes Commented Feb 4, 2021 at 12:16

1 Answer 1

1

It looks like you want to create a link with the URL displayed as its text. You can do the following:

<div v-show="isOpen" class="jwsingle__player__text__description">
  <a :href="text">{{ text }}</a>
</div>

The : in front of :href is important as it binds the prop value of text instead of the string "text".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.