[Vuejs]-V-for cannot read prop data

3👍

v-for="r in parseInt(rating)"

1👍

Pass the value as an integer by adding binding sign : to the passed prop, because it’s a string, and has only one length, that’s why it’s not iterating.

<div>
    <ratings :rating="4"></ratings>
</div>

If the value is coming from server or other place, convert the value into loop, like this:

 <i class="fa fa-star text-warning fa-2x" v-for="r in parseInt(rating)" :key="r"></i>

0👍

I solve this problem via

<ratings :rating="parseInt(4)"></ratings>

Leave a comment