更新记录
1.0.0(2025-03-19)
- UxFrame MQTT 插件,支持Android、iOS、Web
平台兼容性
App |
快应用 |
微信小程序 |
支付宝小程序 |
百度小程序 |
字节小程序 |
QQ小程序 |
HBuilderX 3.6.8,Android:支持,iOS:支持,HarmonyNext:不确定 |
× |
× |
× |
× |
× |
× |
钉钉小程序 |
快手小程序 |
飞书小程序 |
京东小程序 |
鸿蒙元服务 |
× |
× |
× |
× |
× |
H5-Safari |
Android Browser |
微信浏览器(Android) |
QQ浏览器(Android) |
Chrome |
IE |
Edge |
Firefox |
PC-Safari |
√ |
√ |
√ |
√ |
× |
× |
× |
× |
× |
UxFrame MQTT SDK 1.0.0
特别说明
如果您已经购买了UxFrame 低代码高性能UI框架, 则无需再次购买本插件,请点击上方进入交流群
联系我免费获取离线版插件!
使用方法
import { UxMqtt, UxMqttOptions, UxMqttConnectOptions, UxMqttSubscribeOptions, UxMqttPublishOptions } from '@/uni_modules/ux-mqtt'
const online = ref(false)
const msgList = ref<string[]>([])
const mqtt = new UxMqtt({
brokerUrl: 'tcp://localhost:1883',
clientId: '1',
connectionTimeout: 1,
} as UxMqttOptions)
function connect() {
mqtt.connect({
statusListener: (status: boolean, err: string) => {
online.value = status
if(err != '') {
uni.showModal({
content: err
})
}
},
messageListener: (topic: string, msg: string) => {
msgList.value.push(topic + ': ' + msg)
}
} as UxMqttConnectOptions)
}
function disconnect() {
mqtt.disconnect()
}
function subscribe() {
mqtt.subscribe({
topic: 'test',
success: () => {
console.log('subscribe success');
},
fail: (err: string) => {
console.log(err);
}
} as UxMqttSubscribeOptions)
}
function publish() {
mqtt.publish({
topic: 'test',
msg: JSON.stringify({
name: 'hh',
value: 1
})
})
}
文档教程 ⬇️
https://www.uxframe.cn