一款基于react-native harmonyOS 封装的【文档】文件预览查看开源库(基于Harmony 原生文件预览服务进行封装)
本库基于Android、iOS
https://github.com/philipphecht/react-native-doc-viewer扩展而来
这是一款基于 React Native HarmonyOS 端文件文档查看器(pdf、png、jpg、xml、xls、doc、ppt、xlsx、docx、pptx 等)开源插件
版本:latest
react-native-ohos-docviewer
[!TIP] Github 地址
安装与使用
npm
npm install react-native-ohos-docviewer
yarn
yarn add react-native-ohos-docviewer
下面的代码展示了这个库的基本使用场景:基于
[!WARNING] 使用时 import 导入的库名不变。因为该库具有 alias 别名: react-native-doc-viewer [主要是统一 android/ios import 导入]
import React, { useEffect } from \"react\";import { Button, DeviceEventEmitter, SafeAreaView, StatusBar, StyleSheet,} from \"react-native\";import OpenFile from \"react-native-doc-viewer\";import { getBase64ImagePath } from \"./imgbase64\";const App = () => { useEffect(() => { //监听文件预览下载进度 DeviceEventEmitter.addListener(\"RNDownloaderProgress\", (event) => { // 添加事件处理 console.log(\"Download progress:\", event.progress); }); return () => { // 清理事件监听器 DeviceEventEmitter.removeAllListeners(\"RNDownloaderProgress\");