国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專(zhuān)欄INFORMATION COLUMN

React Native 文檔查看組件

leone / 3541人閱讀

摘要:文檔查看組件,可以在手機(jī)上直接打開(kāi)文檔,支持遠(yuǎn)程和本地文檔。

本文原創(chuàng)首發(fā)于公眾號(hào):ReactNative開(kāi)發(fā)圈,轉(zhuǎn)載需注明出處。

React Native 文檔查看組件:react-native-doc-viewer,可以在手機(jī)上直接打開(kāi)文檔,支持遠(yuǎn)程和本地文檔。支持的文檔格式:xls,ppt,doc,xlsx,pptx,docx,png,jpg,pdf,mp4。支持iOS和Android。

安裝方法
npm install react-native-doc-viewer --save
react-native link react-native-doc-viewer
API說(shuō)明

openDoc 打開(kāi)遠(yuǎn)程貨或本地文檔

openDocb64 打開(kāi)Base64字符串格式文檔

openDocBinaryinUrl 打開(kāi)二進(jìn)制文件

playMovie 打開(kāi)視頻文件

使用示例
import React, { Component } from "react";
import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    Platform,
    Button,
    Alert,
    ActivityIndicator
} from "react-native";
import OpenFile from "react-native-doc-viewer";
var RNFS = require("react-native-fs");
var SavePath = Platform.OS === "ios" ? RNFS.MainBundlePath : RNFS.DocumentDirectoryPath;
export default class Component02 extends Component {

    static navigationOptions = ({ navigation }) => ({
        title: `${navigation.state.params.name}`,
    });

    state = { animating: false }
    /*
    * Handle WWW File Method
    * fileType Default == "" you can use it, to set the File Extension (pdf,doc,xls,ppt etc) when in the Url the File Extension is missing.
    */
    handlePress = () => {
        this.setState({ animating: true });
        if (Platform.OS === "ios") {
            OpenFile.openDoc([{
                url: "https://calibre-ebook.com/downloads/demos/demo.docx",
                fileNameOptional: "test filename"
            }], (error, url) => {
                if (error) {
                    this.setState({ animating: false });
                } else {
                    this.setState({ animating: false });
                    console.log(url)
                }
            })
        } else {
            //Android
            this.setState({ animating: true });
            OpenFile.openDoc([{
                url: "https://www.huf-haus.com/fileadmin/Bilder/Header/ART_3/Header_HUF_Haus_ART_3___1_.jpg", // Local "file://" + filepath
                fileName: "sample",
                cache: false,
                fileType: "jpg"
            }], (error, url) => {
                if (error) {
                    this.setState({ animating: false });
                    console.error(error);
                } else {
                    this.setState({ animating: false });
                    console.log(url)
                }
            })
        }

    }


    /*
    * Handle Local File Method
    * fileType Default == "" you can use it, to set the File Extension (pdf,doc,xls,ppt etc) when in the Url the File Extension is missing.
    */
    handlePressLocal = () => {
        this.setState({ animating: true });
        if (Platform.OS === "ios") {
            OpenFile.openDoc([{
                url: SavePath + "demo.docx",
                fileNameOptional: "test filename"
            }], (error, url) => {
                if (error) {
                    this.setState({ animating: false });
                } else {
                    this.setState({ animating: false });
                    console.log(url)
                }
            })
        } else {
            OpenFile.openDoc([{
                url: SavePath + "demo.jpg",
                fileName: "sample",
                cache: false,
                fileType: "jpg"
            }], (error, url) => {
                if (error) {
                    this.setState({ animating: false });
                } else {
                    this.setState({ animating: false });
                    console.log(url)
                }
            })

        }

    }

    /*
    * Binary in URL
    * Binary String in Url
    * fileType Default == "" you can use it, to set the File Extension (pdf,doc,xls,ppt etc) when in the Url you dont have an File Extensions
    */
    handlePressBinaryinUrl = () => {
        this.setState({ animating: true });
        if (Platform.OS === "ios") {
            OpenFile.openDocBinaryinUrl([{
                url: "https://storage.googleapis.com/need-sure/example",
                fileName: "sample",
                fileType: "xml"
            }], (error, url) => {
                if (error) {
                    console.error(error);
                    this.setState({ animating: false });
                } else {
                    console.log(url)
                    this.setState({ animating: false });
                }
            })
        } else {
            OpenFile.openDocBinaryinUrl([{
                url: "https://storage.googleapis.com/need-sure/example",
                fileName: "sample",
                fileType: "xml",
                cache: true
            }], (error, url) => {
                if (error) {
                    console.error(error);
                    this.setState({ animating: false });
                } else {
                    console.log(url)
                    this.setState({ animating: false });
                }
            })
        }
    }
    /*
    * Base64String
    * put only the base64 String without data:application/octet-stream;base64
    * fileType Default == "" you can use it, to set the File Extension (pdf,doc,xls,ppt etc) when in the Url you dont have an File Extensions
    */
    handlePressb64 = () => {
        this.setState({ animating: true });
        if (Platform.OS === "ios") {
            OpenFile.openDocb64([{
                base64: "",
                fileName: "sample.png",
                fileType: "png"
            }], (error, url) => {
                if (error) {
                    console.error(error);
                    this.setState({ animating: false });
                } else {
                    console.log(url)
                    this.setState({ animating: false });
                }
            })
        } else {
            OpenFile.openDocb64([{
                base64: "",
                fileName: "sample",
                fileType: "png",
                cache: true
            }], (error, url) => {
                if (error) {
                    console.error(error);
                    this.setState({ animating: false });
                } else {
                    console.log(url)
                    this.setState({ animating: false });
                }
            })
        }
    }

    /*
    * mp4 Video
    */
    handlePressVideo(video) {
        this.setState({ animating: true });
        if (Platform.OS === "ios") {
            OpenFile.playMovie(video, (error, url) => {
                if (error) {
                    console.error(error);
                    this.setState({ animating: false });
                } else {
                    console.log(url)
                    this.setState({ animating: false });
                }
            })
        } else {
            this.setState({ animating: false });
            Alert.alert("Coming soon for Android")
        }
    }

    setToggleTimeout() {
        this.setTimeout(() => {
            this.setState({ animating: !this.state.animating });
            this.setToggleTimeout();
        }, 2000);
    }

    render() {
        return (

            
                
                
                    Doc Viewer React Native
        
                
Screenshots

示例源碼

GitHub - forrest23/ReactNativeComponents: React Native組件大全

組件地址

GitHub - philipphecht/react-native-doc-viewer: React Native Doc Viewer (Supports file formats: xls,ppt,doc,xlsx,pptx,docx,png,jpg,pdf)

舉手之勞關(guān)注我的微信公眾號(hào):ReactNative開(kāi)發(fā)圈

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://m.specialneedsforspecialkids.com/yun/92045.html

相關(guān)文章

  • ReactNative開(kāi)發(fā)常用的三方模塊

    摘要:寫(xiě)在前面一個(gè)好的缺不了好的三方支持,生活在這個(gè)活躍的開(kāi)源社區(qū),尋找合適的三方組件是一個(gè)開(kāi)發(fā)者最基本的能力。下面分享幾個(gè)我收集的三方模塊,希望對(duì)大家有點(diǎn)幫助。 寫(xiě)在前面 一個(gè)好的App缺不了好的三方支持,生活在ReactNative這個(gè)活躍的開(kāi)源社區(qū),尋找合適的三方組件是一個(gè)開(kāi)發(fā)者最基本的能力。不過(guò)不積跬步,無(wú)以至千里,不積小流,無(wú)以成江海。下面分享幾個(gè)我收集的三方模塊,希望對(duì)大家有點(diǎn)幫...

    frolc 評(píng)論0 收藏0
  • 小哥哥小姐姐看過(guò)來(lái),這里有個(gè)組件庫(kù)需要您簽收一下

    摘要:如果你想減少包大小,你可以這樣引入事實(shí)上,每個(gè)組件都是支持單獨(dú)安裝的,我們也推薦你使用這種方式引入組件。以下是運(yùn)行示例后各界面的截圖組件圖標(biāo)右上角的圓形徽標(biāo)數(shù)字。 1. 前言 一直以來(lái)都想做個(gè)組件庫(kù),一方面是對(duì)工作中常遇問(wèn)題的總結(jié),另一方面也確實(shí)能夠提升工作效率(誰(shuí)又不想造一個(gè)屬于自己的輪子呢~),于是乎就有了本文的主角兒rn-components-kit。 市面上web的UI組件庫(kù)如...

    Alan 評(píng)論0 收藏0
  • 前端進(jìn)階(7) - react、vue 組件開(kāi)發(fā)利器:storybook

    摘要:組件開(kāi)發(fā)利器對(duì)于前端開(kāi)發(fā)來(lái)說(shuō),組件化技術(shù)已經(jīng)是一門(mén)必修課了,這其中又主要以和為主。 react、vue 組件開(kāi)發(fā)利器:storybook 對(duì)于前端開(kāi)發(fā)來(lái)說(shuō),組件化技術(shù)已經(jīng)是一門(mén)必修課了,這其中又主要以 react 和 vue 為主。但平時(shí)在開(kāi)發(fā)組件,尤其是公共組件或者第三方組件庫(kù)的時(shí)候,往往會(huì)有一些困擾: 不能很好的管理多個(gè)組件,尤其是在組件預(yù)覽的時(shí)候,不能一目了然 在組件預(yù)覽的時(shí)候...

    miya 評(píng)論0 收藏0
  • 11個(gè)React Native 組件庫(kù)和 Javascript 數(shù)據(jù)可視化庫(kù)

    摘要:數(shù)據(jù)可視化庫(kù)超過(guò)的的可能是最流行和最廣泛的數(shù)據(jù)可視化庫(kù)。是一組組件,用于高效地渲染大型列表和表格數(shù)據(jù)。一種優(yōu)雅而靈活的方式,可以利用組件來(lái)支持實(shí)際的數(shù)據(jù)可視化。 想閱讀更多優(yōu)質(zhì)文章請(qǐng)猛戳GitHub博客,一年百來(lái)篇優(yōu)質(zhì)文章等著你! React Native 組件庫(kù) 1. NativeBase showImg(https://segmentfault.com/img/bVbrLHH?w=...

    tangr206 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<