Answer the question
In order to leave comments, you need to log in
How to pass an object to all components (global visibility)?
To understand the essence of the issue, I created a sandbox.
How to make the "client" object from main.js visible in the App.vue component, its descendants and other js files
https://codesandbox.io/s/vue-template-qmdr7
Answer the question
In order to leave comments, you need to log in
const createClient = XMPP.createClient({
jid: "[email protected]",
password: "1",
transport: "websocket",
wsURL: "ws://example.com/xmpp-websocket"
});
Vue.prototype.$createClient = createClient;
export default {
name: "App",
created: function() {
console.log(this.$createClient)
}
};
</script>
option 1 (correct): in the Mounted() method, make a request
export default {
data() {
return {
client: {},
}
},
mounted() {
var client = XMPP.createClient({
jid: "[email protected]",
password: "1",
transport: "websocket",
wsURL: "ws://example.com/xmpp-websocket"
});
this.client = client
}
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question