. #11659
-
Context I used getCurrentInstance()!.appContext.config.globalPropertiesgetCurrentInstance().appContext.config.globalProperties to get the router instance but I gone through a couple of discussions threads on github which states that this should not be used. I also saw a couple of references in other vue libraries to be using this for e.g. in element-plus https://github.com/element-plus/element-plus/blob/4984d1b01410e045424dfaa668a0ce59bfaa70d7/packages/components/menu/src/menu.ts#L197 When looked Inside code it has been mentioned that it has been exported for advanced usage and not marked as internal ref - core/packages/runtime-core/src/index.ts Line 102 in 928af5f core/packages/runtime-core/src/component.ts Line 312 in 928af5f Given my scenario please help me to clarify whether I can rely on getCurrentInstance()!.appContext.config.globalProperties or any other property like getCurrentInstance().proxy mentioned here vuejs/vue#12596 (comment)? If not then how can I access global properties inside composition setup? Please help me to get the correct solution 🙏 🙏 🙏 Let me know if anything else needs to be clarified by my side. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You might find this related discussion helpful: #11486. |
Beta Was this translation helpful? Give feedback.
It's understandable to want to keep things simple. Using this for your specific use case should be fine as long as you're aware of the potential risks. Just keep in mind that since it's not part of the public API, there might be changes in the future that could affect its behavior.
If stability is a concern, you might want to consider alternative approaches or ensure you have fallback options in place.