November 2017
Beginner to intermediate
398 pages
8h 42m
English
Inside the methods, we can access the Vue instance with the this keyword. For example, we could call another method:
methods: {
saveNote (val) {
console.log('saving note:', val)
localStorage.setItem('content', val)
this.reportOperation('saving')
},
reportOperation (opName) {
console.log('The', opName, 'operation was completed!')
},
},
Here, the saveNote method will be called from the contentChanged method.
We can also access the other properties and special functions of our Vue instance through this. We could remove the saveNote argument and access the content data property directly:
methods: {
saveNote () {
console.log('saving note:', this.content)
localStorage.setItem('content', this.content)
},
},
This also works ...
Read now
Unlock full access