1

I have an info-card.vue component that is used twice in a landing page, but I want different data displayed in each of them. Here is the info-card.vue component:

<template>
    <div class="card-container glass-effect">
        <div class="illustration-container">
            <img src="{{ image }}" alt="Businesses" class="illustration">
        </div>

        <div class="title-container">{{ title }}</div>

        <div class="paragraph-container">{{ content }}</div>
    </div>
</template>

<script>
export default {
    props: ['image','title', 'content']
}
</script>

And here is the landing-info.vue page that the info-card component is used in:

<div class="business-side">
    <info-card image="/images/image1.png" title="BUSINESSES" content="This is some content"></info-card>
</div>

<div class="customer-side">
    <info-card image="/images/image2.png" title="CUSTOMERS" content="This is some content"></info-card>
</div>

But this didn't work, I'm new to vue so any ideas?

1
  • :src="image". The colon is important. Commented Oct 23, 2021 at 23:46

1 Answer 1

4

You can't use mustache {{   }} in vue attributes. Instead use v-bind:attr="" or :attr="" where attr is the dynamic attribute you want to bind.

So, your image component should be:

<img v-bind:src="image" alt="Businesses" class="illustration" />

or

<img :src="image" alt="Businesses" class="illustration">

The colon is a shorthand for v-bind. Read more on v-bind here.

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.