Welcome back! 🤩
Last time we took at conditional rendering with v-if and v-show. This time we will learn how to loop through arrays and objects an...
For further actions, you may consider blocking this person and/or reporting abuse
Thanks for the tutorial, Marina. Here's my solution:
HTML:
JS bit:
Now on to the next! :D
Yay, thanks for reading!
surprised with the other answer.. short and simple...
why i make it complicated... LOL
btw thanks Marina, nice tutorial
All ways lead to Rome -^ Thanks for reading! <3
great one again. i'm accepting the challenge. i will post my answer soon
w00t!
hey marina please check it and let me know of any improvements or corrections. Thanks
Hey Jonathan, awesome job! I wasn't expecting you to catch on the (game, index) since i didn't cover it on the tutorial - but job well done finding that out on your own! :)
thanks. i will be looking forward to more challanges that pushes me to learn more. I hope you will cover the (game, index) in a different tutorial.
@click="game.rating += 1", adding this on the span also works
HTML:
❤️
js:
methods: {
increaseRatings(game) {
const rate= game.rating++;
this.game.rating = rate;
}
}
<span v-for="star in game.rating" @click="game.rating+=1">❤️</span>
My Solution for the challenge
thepracticaldev.s3.amazonaws.com/i...
It works, but it's a little overkill :) You can pass the whole 'game' object to the function, that way you don't have to
.find
on the array. Also, be careful with==
, as a best practice try to use===
that way you won't run into very hard to understand bugs with types! :Dnoted. Thanks
LOL Fallout 76 not spared here either. Nice post though, you really did not leave any stone unturned
:D Well they really messed up. Also, thanks!
Thanks a lot for sharing v-for. I'm still a bit confused in a few things you've done above.I am a beginner in Vue.js :) Please keep blogging .
Pass game as a parameter.
Then can have ...
methods: {
addRating(game) {game.rating +=1 }
}
So don't need "this."
This is another way to do it :)
please tell me, the v-key attribute should be visible in the markup?thnk u
prntscr.com/smsw3e
prntscr.com/smswmk
Hey Iryna, no it shouldn't be rendered to the markup as it is internal to Vue