Re:Why we chose Vue.js
by Too on Sunday October 23, 2016 @10:15AM
(#12773644)
Yes, v-for is not a for loop in the sense of looping and building up data. It's a pure repeater presenting already existing arrays of data.
Then you get into the gray zone with filters and v-if but somewhere you have to do switching and for many things, having the code where it is actually used makes most sense.
The data should decide what will show up and the template should decide how. Eg: if data.ok img.url=ok.png else img.url=error.png
The if there is totally okay to have in your template because it's deciding how the data should be presented. The data model should not need to know which images are being used, or even care that you are using images at all.
Then you get into the gray zone with filters and v-if but somewhere you have to do switching and for many things, having the code where it is actually used makes most sense.
The data should decide what will show up and the template should decide how. Eg: if data.ok img.url=ok.png else img.url=error.png
The if there is totally okay to have in your template because it's deciding how the data should be presented. The data model should not need to know which images are being used, or even care that you are using images at all.