3 ms·
I'd only heard of Vue as a name before this, but I followed the link to the documentation, which looks fantastic: <div id="app"> {{ message }} </
by OJFord 10y ago
I'd only heard of Vue as a name before this, but I followed the link to the documentation, which looks fantastic:
<div id="app">
{{ message }}
</div>
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
}
})
> Hello Vue!
> This looks pretty similar to just rendering a string template, but Vue has done a lot of work under the hood. The data and the DOM are now linked, and everything is now reactive. How do we know? Just open your browser’s JavaScript console (right now, on this page) and set app.message to a different value.
I guess that didn't take any extra work to setup, since it's a fair assumption the Vue docs are rendered with Vue (!) - but a really easy yet nicely motivating introduction.
Obviously this isn't too tricky with 'vanilla' JS, but there's certainly more ceremony involved, and I'm sure the templates can be more complex such that the JS/Vue contrast would be much greater.
- mgkimsal 10y agovue feels to me like a condensed knockout. i still use knockout on some projects, but have used vue on a couple new ones too. as much as I'd like to see knockout progress - simplify a bit more to be more compact like vue, i'll take vue if that never happens. anyone using knockout looking to migrate, vue is a worthy spiritual successor imo.
- skrebbel 10y agoDo you end up using View Models in Vue just like you might in Knockout? To me, a big benefit of React is making that translation step implicit; I like the idea of View Models but in practice I'm just schlepping a lot of data around between the models and view models.
- mgkimsal 10y agoIt feels like I'm using view models, but I don't think I am. The idea of a 'vue object' ties some metadata, data and methods together, which seems like a somewhat tighter coupling, but also a bit more pragmatic (less "schlepping"). I'm no expert in either, but one of the things I liked about knockout early on was that it was pretty straightforward to decorate existing pages with knockout functionality, and vue has been the same way. Technically react may be the same way, but it never felt as easy as vue or ko. (I've only recently done some 'hello world' stuff in react, so again, no expert) I do have production code with knockout in multiple project spanning back about 4 years or so, so that's where my current comfort-zone is, but vue is starting to replace that. https://vuejs.org/v2/guide/comparison.html#Knockout https://vuejs.org/v2/guide/comparison.html#Knockout has a very short comparison, but they link to a "todo list" gist here comparing the two sets of code: https://gist.github.com/chrisvfritz/9e5f2d6826af00fcbace7be8f6dccb89 https://gist.github.com/chrisvfritz/9e5f2d6826af00fcbace7be8...
- dahauns 10y agoHeh, after a quick look at the examples I tend to agree. Looks actually a lot like durandal (lifecycle hooks!) plus the knockout.punches syntax enchancements (the local filters look nice!), minus the dreaded parentheses. :)
- OJFord 10y ago> I followed the link to the documentation, which looks fantastic It is fantastic, and engrossing. After I said that this morning I tabbed back to the docs and read through 'cover' to 'cover'. Great docs, and looks like a great framework - I think that I could read through and understand the whole thing with very little JS knowledge is testament to that.
- connorshea 10y agoThe Vue docs are seriously amazing, I couldn't rap my head around React fully because its docs just weren't very good (though they've improved them since I last tried).