当前位置: 首页 > article >正文

【每日学点鸿蒙知识】调试、网络、缓存、富文本编辑等

1、如何使用发布证书进行调试?

由于部分功能需要校验证书信息,所以需要使用调试证书和发布证书分别进行调试,但是使用发布证书后出现安装错误05/14 19:04:39: Install Failed: error: failed to install bundle.code:9568322error: signature verification failed due to not trusted app source.View detailed instructions.$ hdc shell rm -rf data/local/tmp/c07053e4cafe4f06bbbfecc3c2a697bbError while Deploy Hap。

规格问题;应用市场发布的发布证书,无法通过非应用市场渠道安装

如需要测试发布证书应用,可以考虑使用AGC->开放式测试

2、获取网络能力netBearType文档中定义为数组类型,是否是当前规格?

netBearType参数当wifi、蜂窝网络同时连接即双开场景下只会返回wifi的状态信息,使用时可能涉及多次调用情况定义为当前规格。

3、RichEditor上面有个Component,现在希望RichEditor和Component成为一个整体,能够自适应光标位置进行滚动,该如何实现?

RichEditor上面有个Component,现在希望RichEditor和Component成为一个整体,能够自适应光标位置进行滚动,应该如何实现,目前用Scroller无法获取RichEditor中光标的具体坐标(光标基于RichEditor的x和y位置),无法实现滚动。

用Scroll将RichEditor和Component包裹,通过onAreaChange的回调,调用scroller.scrollBy的能力,以此来改变滚动组件的高度。

参考代码:

@Entry
@Component
struct Index {
  editorController = new RichEditorController()
  scroller: Scroller = new Scroller()

  build() {
    Column() {
      Scroll(this.scroller) {
        Column() {
          Image($r('app.media.startIcon'))
            .width('100%')
            .height(200)
            .margin({ bottom: 20 })
          RichEditor({ controller: this.editorController })
            .id('RichEditor')
            .width('100%')
            .backgroundColor(Color.Yellow)
            .onReady(() => {
              this.editorController.addImageSpan($r("app.media.startIcon"),
                {
                  imageStyle:
                  {
                    size: ["100px", "100px"]
                  }
                })
              this.editorController.addTextSpan('男生女生向前冲',
                {
                  style:
                  {
                    fontColor: Color.Blue,
                    fontSize: 30
                  }
                })
            })
            .onAreaChange((_, value) => {
              if (_.height !== value.height) {
                this.scroller.scrollBy(0, Number(value.height) - 200)
                console.log('---_.height', _.height)
                console.log('---value.height', value.height)
              }
            })
          Button('getSpans-文字').onClick((event: ClickEvent) => {
            let getSpans = this.editorController.getSpans({ start: 0 })
            console.log('getSpans0' + JSON.stringify(getSpans[0]))
            // 必须进行强转才能获取文字信息或者图片信息
            let span0 = getSpans[0] as RichEditorTextSpanResult
            console.log('文字相关的信息: ' + JSON.stringify(span0))
          })
          Button('getSpans-图片').onClick((event: ClickEvent) => {
            let getSpans = this.editorController.getSpans({ start: 0 })
            console.log('getSpans1' + JSON.stringify(getSpans[1]))
            let span1 = getSpans[1] as RichEditorImageSpanResult
            console.log('图片相关的信息: ' + JSON.stringify(span1))
          })
          Button('RichEditor获焦').onClick(() => {
            focusControl.requestFocus('RichEditor')
          })
        }
      }
      .scrollable(ScrollDirection.Vertical) // 滚动方向纵向
      .scrollBar(BarState.On) // 滚动条常驻显示
      .scrollBarColor(Color.Gray) // 滚动条颜色
    }
  }
}

4、LocalStorage和APPStorage保存复杂对象会产生性能问题的原因?

关于LocalStorage和APPStorage保存复杂对象性能问题的两点疑问:

  1. 频繁读写:频繁读写复杂对象时,为什么会导致页面的性能变差,是LocalStorage会影响页面的渲染吗?
  2. 数据结构:LocalStorage和APPStorage会把数据保存到本地吗?应该在内存里边吧,为什么会有序列化和反序列化的过程?

LocalStorage的读写操作是同步的,即当读取或写入LocalStorage时,程序会阻塞等待操作完成才会继续执行后续代码,所以不推荐整改修改复杂对象,这个new创建的时长是会影响刷新效率的;

LocalStorage和APPStorage在本地读取复杂对象时,不会进行序列化。

5、无网络环境下使用同步方法获取网络状态报错?

无网环境调用同步方法请求无法解析拿到nethandle对应内容,方法内部执行到getCap时产生报错,可采用try-catch方式获取报错信息:

try {
  let netHandle = connection.getDefaultNetSync();
  let connectionproperties = connection.getConnectionPropertiesSync(netHandle);
} catch(err) {
  console.info('error: ' + JSON.stringify(err));
}

http://www.kler.cn/a/488203.html

相关文章:

  • Unity学习之UGUI进阶
  • android studio使用DataBinding
  • Unity使用Vuforia插件进行AR开发
  • Django REST framework 源码剖析-视图集详解(ViewSet)
  • 使用Logstash 将Mysql的数据导入ElasticSearch中
  • (超详细)Maven安装配置、以及在IDEA中创建Maven项目
  • LeetCode 2765. 最长交替子数组解析与解题思路
  • 机器学习之过拟合(算法参数,超参数) 欠拟合(模型参数)
  • 简单的spring boot tomcat版本升级
  • 解决Qt打印中文字符出现乱码
  • plane开源的自托管项目
  • 《Spring Framework实战》13:4.1.4.4.延迟初始化Bean
  • qml Column详解
  • 0109鹅厂面经
  • 媒体资源生产转码过程
  • Formality:默认配置文件
  • 国产信创实践(国能磐石服务器操作系统CEOS +东方通TongHttpServer)
  • 【海南省】乡镇界arcgis格式shp数据乡镇名称和编码gis矢量数据
  • 设TCP的门限值的初始值为10个报文段,当拥塞窗口上升到24时网络发生了超时,TCP使用慢开始和拥塞避免后第一轮的拥塞窗口大小是,门限值为
  • pytorch torch.clamp函数介绍