[Vuejs]-Manipulating the data value in Vue.js

1👍

You can use one of the life-cycle hooks like created created or mounted for setting initial data, loading data from API, etc, like following:

var app = new Vue({
  el: '#app',
  data: {
    name: '',
    object: { "personOne": "Alex", "personTwo": "Jack"}
  },
  methods: {
    setName (name) {
      this.name = name
    }
  },
  mounted () {
     this.setName(this.object.personOne)
  },
})

1👍

From within the Vue object you write

this.name = 'Alex' and outside you write app.name = 'Alex'

app.someDataField will change the data property called someDataField

Leave a comment