So I'm wondering how I can include another JavaScript file as is. Much like PHP's include function/keyword. I'm not looking for the export function, as that just allows you to use variables from other files.
I'm using vue init webpack my-project.
Here's what I basically have (Vue):
mounted () {
socket = io("http://localhost:8081")
socket.connect()
// ensure server has actually put us in a room
socket.on("find game", () => {
this.gameSearch = "finding"
})
...
}
So basically I have a whole heap of socket.on that I would like to move into another file. I'm wondering how I could I could include them as is so that they would work as if the code was already inserted there (like PHP's include)
What it might look like in the end:
mounted () {
<socket.js file>
}
socket.js
socket = io("http://localhost:8081")
socket.connect()
// ensure server has actually put us in a room
socket.on("find game", () => {
this.gameSearch = "finding"
})
...
vue-cli. Sovue init webpack my-project..onfunctions to occur once the component is mounted. Maybe I'll just try exporting the socket and see what happens tomorrow.