1

Let's say I have this html element

<div class="progress-bar w-90"></div>

and I want to replace 90 with an object from vue. I tried below but syntax

<div :class="progress-bar w-{{ progress.value }}"></div>
1
  • 2
    you can try this <div :class="`progress-bar w-${progress.value}`"></div> Commented Dec 7, 2020 at 4:49

2 Answers 2

2

You cannot use {{ }} in attribute/props, better to use template literals as below.

<div :class="`progress-bar w-${progress.value}`"></div>
Sign up to request clarification or add additional context in comments.

Comments

1

You can achieve text-binding in this way

<div :class="'progress-bar w-'+progress.value"></div>

1 Comment

@Steve - Great! If it works for you and you are happy - then in general you would accept the answer. This will not only help other people with the same issue but it will also mean people are more likely to help you in the future with any other issues you have. Thankyou

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.