HarmonyOS从9升级到11后 http和mqtt 都报错 无法编译了

import { MqttAsync,MqttClient, MqttQos, MqttSubscribeOptions } from '@ohos/mqtt' 
export class MyMqttClient { 
  private mqttClient : MqttClient ; 
  提示: 
    Property 'mqttClient' has no initializer and is not definitely assigned in the constructor. <ArkTSCheck> 
  await response.then((data) => { 
  const code = data.responseCode 
  if (code == 200) { 
  console.info('http code:' + code); 
  responsedata = JSON.parse(data.result.toString()); 
  const userPhone = responsedata .data.user.user_phone; 
  const username = responsedata .data.mqtt.username; 
  const token = responsedata .data.token; 
  console.log("http user_phone:", userPhone); 
  console.log("http username:", username); 
  console.log("http token:", token); 
}else{ 
  console.info('http code!:' + code+" "+data.result.toString()); 
  console.info("http token:", token); 
} 
}).catch((err:string) => { 
  console.info('error:' + JSON.stringify(err)); 
}) 
提示: 
  Use explicit types instead of "any", "unknown" (ArkTS-no-any-unknown) <ArkTSCheck>
HarmonyOS
2024-09-13 10:13:28
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
zbw_apple

API升级后对部分语法检查更严格,看报错内容是没有对参数进行初始化赋值以及没有使用正确的数据类型。

分享
微博
QQ
微信
回复
2024-09-13 16:02:41
相关问题
IDE3.14.1,预览器启动报错
32浏览 • 1回复 待解决
升级到next版,oaid是否会变?
1800浏览 • 1回复 待解决
android 应用升级到鸿蒙应用
2677浏览 • 0回复 待解决
ide升级到canary3模拟器频繁崩溃
210浏览 • 1回复 待解决
RDS MySQL8.0如何升级到PolarDB MySQL?
3081浏览 • 1回复 待解决