HarmonyOS PDF组件无法滑动?

能打开PDF第一页,但是无法查看其他页。pdfview自己实现了滑动操作,在pdfview组件外套scroll会导致事件被scroll抢占导致无法滑动

import { pdfService, pdfViewManager, PdfView } from '@kit.PDFKit'
import { common } from '@kit.AbilityKit';
import { fileIo } from '@kit.CoreFileKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { router } from '@kit.ArkUI';

@Entry
@Component
struct PDFPage {
  private controller: pdfViewManager.PdfController = new pdfViewManager.PdfController();
  private params?:PDFPageData
  aboutToAppear(): void {
    let context = getContext() as common.UIAbilityContext;
    let option  = router.getParams()
    if ((option as PDFPageData).filePath != undefined){
      this.params = option as PDFPageData
    }
    // 确保rawfile里面有pdf文件
    let filePath: string =""
    if(this.params!=undefined){
      filePath=this.params.filePath
    }

    this.controller.loadDocument(filePath, '', 0, (progress: number) => {
      return progress;
    }).then((v)=>{
      // let loadResult: pdfService.ParseResult = v
      // if (pdfService.ParseResult.PARSE_SUCCESS === loadResult) {
      //   this.controller.setViewOffset(0.5, 0.5, true);
      // }
    })

  }

  build() {
    Scroll() {
      PdfView({
        controller: this.controller,
        pageFit: pdfService.PageFit.FIT_WIDTH,
        showScroll: true
      })
    }
    .width('100%')
    .height('100%')
  }
}

export interface PDFPageData{
  filePath:string
  title:string
}
阅读 523
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进