How can I set the value of name to the property personOne in object? So that name will have the value of Alex.
var app = new Vue({
el: '#app',
data: {
name: '',
object: { "personOne": "Alex", "personTwo": "Jack"}
}
})
How can I set the value of name to the property personOne in object? So that name will have the value of Alex.
|
|||
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:
|
|||||||||||||
|
From within the Vue object you write
app.someDataField will change the data property called someDataField |
|||
|
name: 'Alex'
and be done with it. Are you loadingobject
via AJAX or something? If so, acomputed
property is probably reasonable. – ceejayoz Jan 22 at 3:01personOne: 'Alex'
– Belmin Bedak 2 days ago