热门问题
待回答
最新问题
热门回答
  • 1

    回答

    1103

    浏览
    HarmonyOS Worker相关问题

    app需要实现本地日志的持久化,计划把日志存在数据库中。1、主线程postMessage日志到worker中。2、worker中做持久化。3、worker中上传服务器。Wordker中如何访问主线程的数据库,目前无法读取。Wordker中无法直接访问主线程的数据库,于是想在worker中创建数据库,context如何获取?

    HarmonyOS
      superinsect 进行了回答 • 2024-12-23 18:07:16
  • 1

    回答

    1023

    浏览
    HarmonyOS 进制转换问题

    将16进制字符串转换为Uint8Array的方法是什么?

    HarmonyOS
      fox280 进行了回答 • 2024-12-23 18:06:34
  • 1

    回答

    927

    浏览
    HarmonyOS 切换tabs的时候,该如何修改其他图片的背景图片

    写了一个Tabs,然后当切换tabBar的时候,需要改正整个页面风格的背景图片,但是这样写BuildertabLabel(title:string,targetIndex:number){if(targetIndex0){this.appResource$r('app.media.icleftarrow')}elseif(targetIndex1){}elseif(targetIndex2){}会提示不允许这种语法,所以应该怎么来实现

    HarmonyOS
      FengTianYa 进行了回答 • 2024-12-23 18:06:31
  • 1

    回答

    962

    浏览
    HarmonyOS 如何实现有符号的数组
    HarmonyOS
      put_get 进行了回答 • 2024-12-23 18:06:28
  • 1

    回答

    1098

    浏览
    HarmonyOS Uint8Array转16进制
    HarmonyOS
      put_get 进行了回答 • 2024-12-23 18:06:18
  • 1

    回答

    830

    浏览
    HarmonyOS instanceof判断失效

    如图传入的两种类型集合的元素判断都无法进入对应分支解决方案通过json转的无法使用instanceof判断,instanceof只能判断new出来的对象。json转换的可以通过判断转换后的属性是否存在来判定是否是同一个对象,参考示例:import{A,B}from'.Index';ComponentexportstructPage{Statemessage:string'HelloWorld';PropcommentData:AB;build(){RelativeContainer(){Text(this.message).id('HelloWorld').fontSize(50).fontWeight(FontW...

    HarmonyOS
      fox280 进行了回答 • 2024-12-23 18:05:41
  • 1

    回答

    1025

    浏览
    HarmonyOS 两个感叹号!!的判断使用问题

    if(!!name&&!!age){....}if(name&&age){....}

    HarmonyOS
      superinsect 进行了回答 • 2024-12-23 18:05:38
  • 1

    回答

    1017

    浏览
    HarmonyOS 字符串如何精确判断是否为空
    HarmonyOS
      superinsect 进行了回答 • 2024-12-23 18:05:19
  • 1

    回答

    832

    浏览
    HarmonyOS v8里面的executeObjectScript executeFunction ,HarmonyOS的jsvm有对应的么

    executeObjectScriptexecuteFunction,HarmonyOSjsvm有对应的吗?

    HarmonyOS
      zxjiu 进行了回答 • 2024-12-23 18:05:11
  • 1

    回答

    960

    浏览
    HarmonyOS @Concurrent方法调用不了当前ets文件内的类

    exportclassAlbum{statictestStatic(){}}ConcurrentexportfunctiontestConcurrent(){constalbumnewAlbum()Album.testStatic()}上述代码在同一个ets文件内写了一个类和一个Concurrent方法,发现方法内找不到Album这个类,按道理同一个文件内是不用import的。这是ide的问题吗,还是需要别的写法?但是如果这个Concurrent方法写到别的文件,可以通过import调到Album的。

    HarmonyOS
      fox280 进行了回答 • 2024-12-23 18:04:46
  • 1

    回答

    937

    浏览
  • 1

    回答

    1145

    浏览
  • 1

    回答

    907

    浏览
    HarmonyOS 应用逻辑出错,app闪退,这是正常的么

    应用逻辑出错app闪退,这是正常的么?

    HarmonyOS
      shlp 进行了回答 • 2024-12-23 18:04:02
  • 1

    回答

    856

    浏览
    HarmonyOS Json字符串包含数字key,应该如何编写数据类,类型是什么?

    以下是接口返回的一段json字符串,在maxranktags内部,可能包含1个或多个数字key和数据结构ShopInfo组成的数据,请问这种情况maxranktags的数据类应该如何编写,对应的类型是什么?数据类格式是ets,尝试过[k:string]:ShopInfo,但报错,猜测是ets文件对类型要求比较严格。另外还尝试过用HashMap,但在代码里get()出来时,报错:TypeError:isnotcallable。{"statuscode":200,"result":{"maxranktags":{"215123565":{"shopid":21...

    HarmonyOS
      Heiang 进行了回答 • 2024-12-23 18:03:55
  • 1

    回答

    1246

    浏览
    HarmonyOS systemapi在agc上有相关的接口文档介绍吗
    HarmonyOS
      superinsect 进行了回答 • 2024-12-23 18:03:36
  • 1

    回答

    755

    浏览
  • 1

    回答

    901

    浏览
    HarmonyOS 各类常见数据的转换

    列如string转number,要怎么实现?

    HarmonyOS
      put_get 进行了回答 • 2024-12-23 18:02:48
  • 1

    回答

    1094

    浏览
    HarmonyOS 泛型构造方法在ets中的实现

    classServiceBuilder{ServiceBuilder的属性和方法}classSomeService{constructor(builder:ServiceBuilder){SomeService的构造函数逻辑}}classServiceFactory{publicbuild(service:new(builder:ServiceBuilder)T):T{returnnewservice(newServiceBuilder());}}示例使用constfactorynewServiceFactory();constserviceInstancefactory.build(SomeService);以上ts中的代码怎么在ets中实现?

    HarmonyOS
      zxjiu 进行了回答 • 2024-12-23 18:02:40
  • 1

    回答

    1334

    浏览
    HarmonyOS 数据模型对象赋值问题

    module.newsList.push这样添加对象,显示错误module.newsList报undefinedHotPageModel.getMoreHotPageList(this.page).then(result{result.object.newsList.forEach(item{letmoduleList:ArraynewArrayletmodulenewModuleListletnewsList1newNewsList()newsList1.iditem.idmodule.newsList.push(newsList1)这个push对象不可以,断点module.newsList报undefinedmoduleList.push(module)module.newsList.push(newsList1)this.hotPa...

    HarmonyOS
      Excelsior_abit 进行了回答 • 2024-12-23 18:01:49
  • 1

    回答

    1036

    浏览
    HarmonyOS ArkTS实现Uint8Array类型转Map有问题

    代码如下:consttemp'eyJ0aW1lc3RhbXAiOiIxNzE5NTgzMjk4MDA3IiwiY2hhbGxlbmdlIjoicXpRaFBvbkdkR2FmVDc2d2dBTmFuUnc2UTE4WE0wengtZUdRNlNPb1Z3bmh2X1kiICwiZG93bmxvYWRDZXIiOiAidHJ1ZSIsInVzZXJWZXJpZmljYXRpb24iOiIyIiAsImRldmljZUlEIjoibWF0ZTMwdGVzdCIgLCJhdXRoVHlwZSI6ImF1dGgiICwiYWRkVXZpIjoibnVsbCIgLCJtb2RlbE51bWJlciI6Im51bGwiIH0'this.serverDataawaitthis.genClientExts(temp);privateasyncgenClientExts(temp:strin...

    HarmonyOS
      zxjiu 进行了回答 • 2024-12-23 18:01:41
  • 1

    回答

    817

    浏览
    HarmonyOS 系统库的Array、Map、ThreadWorker是sendable的么

    在做内存共享的完善,想问下系统库的Array、Map、ThreadWorker是sendable的吗?

    HarmonyOS
      shlp 进行了回答 • 2024-12-23 18:01:31
  • 1

    回答

    979

    浏览
    HarmonyOS ts中继承的类,怎么和C++中的类对象进行绑定

    ts中继承的类怎么和C++中的类对象进行绑定,ts这边有A、B两个类,B继承A,然后A、B在C++都有对应的类。C++这边需要写什么方法支持B调用A的方法呢?

    HarmonyOS
      aquaa 进行了回答 • 2024-12-23 18:01:29
  • 1

    回答

    1408

    浏览
    HarmonyOS Uint8Array转成string后出现乱码

    服务中返回的数据是进行了对象转成byte[],再进行gzip压缩,最后进行base64转码。现在对数据进行处理。先进行base64转uint8Array,再进行解压转字符串处理。上面是找到的两种Uint8Array转字符串的方法,但是都出现了乱码,麻烦看下是那一步出现了问题。

    HarmonyOS
      zxjiu 进行了回答 • 2024-12-23 18:01:07
  • 1

    回答

    804

    浏览
    HarmonyOS uri获取query失败
    HarmonyOS
      aquaa 进行了回答 • 2024-12-23 18:00:57
  • 1

    回答

    959

    浏览
    HarmonyOS 混淆相关问题

    letentry:ValuesBucket{appkey:appkey,time:Date.now(),length:data.length,data:data}if(this.store!undefined){(this.storeasrelationalStore.RdbStore).insert(table,entry,(err:BusinessError,rowId:number){if(err){hilog.error(100,'dtreport',Failedtoinsertdata.Code:${err.code},message:${err.message});return;}hilog.info(100,'dtreport',table${table},Succeededininsertingdata.rowId:${rowId});})}有一段使用rdb...

    HarmonyOS
      FengTianYa 进行了回答 • 2024-12-23 18:00:56
  • 1

    回答

    1191

    浏览
    HarmonyOS ArkTS语法相关

    后缀运算符!可用于断言其操作数为非空,这个空是否包含null和undefined。另外在DevEcoStudio中还可以有!!,甚至很多个!!!都不会报错,那么一个!,两个!!,或者多个的区别是什么?

    HarmonyOS
      Heiang 进行了回答 • 2024-12-23 18:00:48
  • 1

    回答

    453

    浏览
    HarmonyOS 有什么办法能在异步处理多个耗时操作,避免嵌套比较多,最终再统一将结果callback回调回去

    在做的功能是图片拼接,把4张图片拼接成一张图片。拼接逻辑中需要分别把4张图片解码转成pixelMap,再分别写到新的pixelMap中,这些过程都是耗时的。遇到的问题是,如果都调用异步接口可能会嵌套比较多,如果都调用同步接口那可能会在主线程出现耗时操作。请问是否有办法能在异步处理这些耗时操作,避免嵌套比较多,最终再callback回调结果。

    HarmonyOS
      Heiang 进行了回答 • 2024-12-23 18:00:47
  • 1

    回答

    1067

    浏览
    HarmonyOS C++层如何同步调用JS函数 -

    由于HarmonyOS只在JS提供了API,C++层面要调用的时候,只能通过napi来实现,但目前测试发现,似乎从C++调用JS的结果都只能通过回调来返回,无法直接return,这对目前的核心功能影响很大。是否有C++同步调用JS的方式?

    HarmonyOS
      superinsect 进行了回答 • 2024-12-23 18:00:47
  • 1

    回答

    720

    浏览
    HarmonyOS 如何获取单视图范围内的LocalStorage

    在UI页面上通过LocalStorage.getShared()方法获取到的,是通过loadContent共享的LocalStorage实例。如果entry页面传入的是新建的一个LocalStorage实例而不是共享的LocalStorage实例,在页面上要怎样获取在entry页面传入的这个LocalStorage实例?

    HarmonyOS
      zbw_apple 进行了回答 • 2024-12-23 18:00:34
  • 1

    回答

    2897

    浏览
    HarmonyOS 关于对象数组内容变更不会引起UI刷新

    参考API的链接:https:developer.huawei.comconsumercndocharmonyosguidesV5arktsobservedandobjectlinkV5其中this.arrA[Math.floor(this.arrA.length2)].c,State无法观察到第二层的变化,但是ClassA被Observed装饰,ClassA的属性的变化将被ObjectLink观察到。ObservedexportclassFilterMaterialModel{cover:stringid:stringdescribe:stringnulltitle:stringfileAddress:stringfilterLocalPath:stringdownloadProgress:numberc...

    HarmonyOS
      Excelsior_abit 进行了回答 • 2024-12-23 18:00:07
3.8w问题, 4.1w人参与
94%的提问收到了回答

优秀答主

  • 回答了3个问题,0个赞同
  • 回答了3个问题,1个赞同
  • 回答了3个问题,0个赞同
  • 回答了2个问题,1个赞同
  • 回答了2个问题,0个赞同
  • 写回答 帮助更多的人