HarmonyOS NEXT创建对象提示Object literal must correspond to some explicitly declared class or interface

发布于 1周前 作者 itying888 最后一次编辑是 5天前 来自 分享

HarmonyOS NEXT创建对象提示Object literal must correspond to some explicitly declared class or interface

参考HarmonyOS NEXT系列教程: https://www.itying.com/category-93-b0.html

let userinfo={
  username:"张三",
  age:20,
  sex:"男"
}

解决办法

interface UserInfoInterface{
  username:string,
  age:number,
  sex:string
}

let userinfo:UserInfoInterface={
  username:"张三",
  age:20,
  sex:"男"
}
回到顶部