1var vm = new Vue({
2 el: '#demo',
3 data: {
4 firstName: 'Foo',
5 lastName: 'Bar',
6 fullName: 'Foo Bar'
7 },
8 watch: {
9 firstName: function (val) {
10 this.fullName = val + ' ' + this.lastName
11 },
12 lastName: function (val) {
13 this.fullName = this.firstName + ' ' + val
14 }
15 }
16})
1
2watch: {
3 // whenever question changes, this function will run
4 question(newQuestion, oldQuestion) {
5 // your code
6 }
7},
8