Hello,
I currently have a problem when I try to add a library (peerjs) it's not a bug, it's for sure a lack of experience of my part.
I wanna declare globaly my peerjs , and call it from anywhere , and i really don't know how to do it :/
npm install peerjs --save
in main.js i added : import Peer from 'peerjs' and below Vue.use(Peer)
in my custom component i tryed with this.$Peer('id', {key:'valueofmykey'}) and many other combinations but have that error : Uncaught ReferenceError: Peer is not defined
Someone can help ?
Thx
peerjs is not Vue plugin.
To load a library automatically, you could add ProvidePlugin in your webpack.config.js
See https://webpack.js.org/plugins/provide-plugin/
@Mistes974
Just as @re-fort stated, peerjs alone is not a Vue plugin and cannot be installed directly. To use peerjs in your JS files, simply import it and use it directly. For example...
main.js
// import
import Peer from 'peerjs'
// and use directly
const peer = new Peer('pick-an-id', { key: 'myapikey' })
/* You can then attach this instance to Vue by... */
Vue.prototype.$peer = peer
By doing the above, you can now access it in all component files through this.$peer.
Going to close this as it isn't a direct issue with electron-vue. Feel free to comment back any questions.
Most helpful comment
@Mistes974
Just as @re-fort stated,
peerjsalone is not a Vue plugin and cannot beinstalled directly. To usepeerjsin your JS files, simply import it and use it directly. For example...main.js
By doing the above, you can now access it in all component files through
this.$peer.Going to close this as it isn't a direct issue with electron-vue. Feel free to comment back any questions.