When attempting to migrate a Vue 2 plugin to Vue 3, I encountered an issue in the install function. In Vue 2, I had code that looked like this:
install(Vue, options) {
const reactiveObj = {
// ...
};
Vue.prototype.$obj = Vue.observable(reactiveObj);
}
This allowed me to access this.$obj
in any component and have it reactively update when reactiveObj
changed. However, in Vue 3, my attempt to replicate this behavior resulted in:
import {reactive} from 'vue';
install(app, options) {
const reactiveObj = reactive({
// ...
});
app.config.globalProperties.$obj = reactiveObj;
}
In this case, while I can access this.$obj
, it is now a Proxy object and does not reactively update when reactiveObj
changes. How can I achieve reactivity in this scenario?