I am currently in the process of updating my Vue 2 application to Vue 3 and I have been exploring how to work with computed properties using the Composition API in Vue 3.
One particular challenge I am facing is migrating a Vue 2 computed property that provides common data to multiple components. I am wondering how I can achieve the same functionality in Vue 3 using the Composition API, specifically with getters and setters.
sharingDataInComponents() {
let obj={}, objProperty = Object.defineProperty;
// variables
objProperty(obj, 'size' , {get:()=>this.size});
objProperty(obj, 'shape' , {get:()=>this.shape});
objProperty(obj, 'navigation' , {get:()=>this.navigation});
objProperty(obj, 'addBtn' , {get:()=>this.addBtn});
// functions
objProperty(obj, 'onAddClick', {get:()=>this.onAddClick});
return obj;
},
As I am new to the Vue 3 Composition API, I would appreciate guidance on how to successfully migrate this computed property. Thank you!