4 ms·
Vue has one source of truth: the data stored in each component. You bind elements in the template to that data and they get automatically re-rendered when it ch
by crooked-v 9y ago
Vue has one source of truth: the data stored in each component. You bind elements in the template to that data and they get automatically re-rendered when it changes, and you bind events in the template to methods (or just ad-hoc things like @click="toggleVar = !toggleVar" for a boolean) that update that data.
This includes child components, which trigger events that you bind in the parent component.
- ng12 9y ago> @click="toggleVar = !toggleVar" Oh boy. Another reason why I don't like templates -- you invariably end up with magical incantations like this. Working with JSX has given me an incredible distaste for templating languages.
- afd8856 9y agoSomewhat magical. All bound expressions in Vue are javascript expressions. Names are typically bound on "this", which is the component instance. So the above expression is equivalent to this.toggleVar = !this.toggleVar.
- ng12 9y agoNot entirely true -- I know there's at least special processing for filters: https://vuejs.org/v2/guide/syntax.html#Filters https://vuejs.org/v2/guide/syntax.html#Filters