9 ms·
Can someone give a quick code example for the follwing? The framework allows UI elements to be defined in a declarative way How can you use Vue so tha
by TekMol 7y ago
Can someone give a quick code example for the follwing?
The framework allows UI elements
to be defined in a declarative way
How can you use Vue so that what you do is more declarative then when using a template engine like handlebars?
- aliveupstairs 7y agoI believe the templating is what's declarative, here. For instance, in Vue you can insert logic such as for loops, conditionals, event listeners, two-way data binding and so on right in the template with directives (HTML attributes). <Todo v-for="(todo, index) in Todos" :key="index"/> Instead of an imperative JavaScript for loop.
- otabdeveloper2 7y agoHow in seven hells is moving imperative loop constructs from Javascript to HTML supposed to be "declarative"?! If anything, it's the opposite - you're now polluting HTML with imperative programming features where there previously were none.
- TekMol 7y agoIt is the same with handlebars. You put your todo element between {{#.}} and {{/.}} which means "do this for all elements" and then pass only the "Todos" array to the template. No loop in Javascript either.