vue3+uniapp使用mqtt

1.先在控制台使用npm install [email protected]

2.需要把node_modules里的mqtt文件夹放在外面的目录下

 3.使用文件中引入

4.建立连接

let client  = mqtt.connect(`wxs://xxx/`, options) 

注意这里如果你是连接是ws 的需要改成wx,如果你是wss的需要改成wxs才行!

5.如果上面那种引入报错的话可以试试

    import * as mqtt from 'mqtt/dist/mqtt.min'; 

猜你喜欢

转载自blog.csdn.net/qq_42628556/article/details/130924163
今日推荐