I'm currently using Ajax to populate data properties for multiple objects, but the properties I want to bind to don't exist at the time of binding.
For example:
<template>
<my-list v-bind:dataid="myobject ? myobject.data_id : 0"></my-list>
</template>
<script>
export default {
data () {
return {
myobject: {}
}
}
</script>
The Vue docs suggest initializing data instead of using an empty object.
However, initializing every sub-parameter on all objects can be labor-intensive when dealing with numerous parameters and sub-parameters. For instance:
myobject: { subp1: [], subp2: [] ...}
This becomes especially cumbersome when working with nested structures such as arrays of objects or objects containing sub-arrays of objects.
Is there a more efficient alternative when binding to objects that do not yet exist?