how to convert method to computed property vuejs code example

Example 1: cannot access this from computed vuejs

computed:{
                // Get data from vuex
                $currency(){
                    return this.$store.state.currency
                }
            },

Example 2: computed vue

// ...
computed: {
  fullName: {
    // getter
    get: function () {
      return this.firstName + ' ' + this.lastName
    },
    // setter
    set: function (newValue) {
      var names = newValue.split(' ')
      this.firstName = names[0]
      this.lastName = names[names.length - 1]
    }
  }
}
// ...

Example 3: vue add watcher

vm.$watch('person.name.firstName', function(newValue, oldValue) {
	alert('First name changed from ' + oldValue + ' to ' + newValue + '!');
});

Tags:

Html Example