LoginSignup
0
0

More than 3 years have passed since last update.

vue-cliでsocket.ioを使う方法(socket.io-client)

Last updated at Posted at 2020-04-26

はじめに

 基本的なことだからなのか書いている人があまりいなくて入れるのに少し困ったので書きました。

1. socket.io-clientをインストール

$ npm install socket.io-client

2. socket.ioを使いたいコンポーネントに以下を記述

~
</template>

<script>
import io from 'socket.io-client';  //追加

export default {
    name: 'name',
    data: function(){
        return {
            socket : io('localhost:4000')  //生成
        }
    },
}

おわりに

思いのほか簡単でした!

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0