0

I make progressbar of the user's referrals. As planned, if a user adds +1 referral, the progress bar is filled by %.

There is a finish number - 200. There is user.ref_num - the number of user referrals. So I'm trying to fill in the length of the progress bar, but something doesn't work.

My code:

        <div class="progress-panel-progress">
          <div class="progress-panel-progress__current" v-if="user.ref_num === 0" style="width: 0%;"> </div>
            <div class="progress-panel-progress__current" v-if="user.ref_num > 0" :style="(200 - user.ref_num) / 200 * 100">
            </div>
        </div>

But when i check source code, then I don't see the attribute style= and progressbar doesn't fill.

Where can be a problem?

1 Answer 1

1

You didn't specify which style (width) you want to add.

Your code evaluates only to some Number. Since just a Number is not a correct CSS property, your browser probably strip it out.

Here is a line you need to modify:

<div
  class="progress-panel-progress__current"
  v-if="user.ref_num > 0"
  :style="`width: ${(200 - user.ref_num) / 200 * 100}%;`" // add style width like that
></div>

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.