I'm trying to set a property globally, using Vue.prototype, but I'm having a bit of trouble
I have the following:
microsoftTeams.initialize();
microsoftTeams.getContext((context) => {
Vue.prototype.$teamsContext = true;
});
new Vue({
el: '#overview',
components: {
Index
},
data: {
// add attributes here
},
});
I'm guessing this prevents me from using Vue.prototype inside the getContext call as $teamsContext is never set.
Is there a way around this?
Thanks
EDIT::
I have added some more code.
In the Index component, inside the created() method, I'm doing a console.log("CONTEXT", this.$teamsContext), which returns CONTEXT undefined
getContentcalling your function? Put in some logging or adebuggerstatement to check.getContextasynchronous? I would assume so if it takes a callback. You don't seem to be waiting for it to finish before kicking off your Vue application. Thatcreatedhook will be called before you've set the value. Try putting in console logging in both places and check the order they happen.