Vue使用mqtt插件
1. 下载插件
npm install mqtt
2. 注册插件 main.js(可不用)
import mqtt from "mqtt";
Vue.prototype.$mqtt = mqtt;
3. 设计存放mqtt配置的js
import mqtt from "mqtt";
/*
使用方法
this.client= new initMqtt().connect()
*/
function initMqtt(options) {
const {
hostname,
port,
原创
2020-12-19 19:16:11 ·
754 阅读 ·
7 评论