18 خطوط
368 B
JavaScript
18 خطوط
368 B
JavaScript
// Nuxt 3: plugins/socket.client.js
|
|
import io from 'socket.io-client'
|
|
|
|
export default defineNuxtPlugin(() => {
|
|
const socket = io('http://localhost:3000')
|
|
|
|
socket.on("message", (arg) => {
|
|
console.log(arg); // "world"
|
|
});
|
|
|
|
return {
|
|
provide: {
|
|
socket: socket
|
|
}
|
|
}
|
|
})
|
|
|
|
export const socket = io('http://localhost:3000')
|