====== Vue.js notes ====== ===== Vue.js instance ===== ==== Target what the Vue.js instance operates on ==== * Specify target element:
* Create instance: new Vue({ el: '#vue-thing', data: {}, methods: {} }) * ''this'' refers to the Vue instance. * data is proxied into methods. ===== Outputing literal HTML ===== * Use ''v-html'':
* and data: data: {htmlLit: } * Security? ===== Binding content text ===== ==== Static data ==== * Use handlebars:

{{ name }}

* and data members: data: { name: 'Sigmund' } ==== Computed data using methods ==== * Use handlebars:

{{ greet('Hi') }}

* and methods: methods: { greet: function(s) {return s + ', ' + this.name + '!'} } ==== Computed data using computed properties ==== TODO ===== Binding attributes ===== * Use ''v-bind'': v-bind:="" ... * Shortcut: '':'' is a synonym for ''v-bind:''. ===== Binding events ===== * Use ''v-on'' with single Vue/JS statement: v-on:="" * or method w/parameters: v-on:="(p1, p2)" * or method with event passed in as 1st param: v-on:="" * event handling can be [[https://vuejs.org/v2/guide/events.html#Event-Modifiers|modified]] (prevent, once, etc.): v-on:.="(p1, p2)" * Shortcut: ''@'' is a synonym for ''v-on:''.