zoukankan      html  css  js  c++  java
  • ReactNative: 使用图片存储组件ImageStore组件

    一、简介

    ImageStore组件是ReactNative中用来存储图片的,支持通过uri从内存中获取和移除图片,也支持二进制图片的存储和获取。ImageStore组件提供的API就只有4个静态函数,使用起来比较简单。

    二、API

    1、通过uri获取图片

    //查询图片,两个参数:第一个图片的uri,第二个为查询的回调
    static hasImageForTag(uri: string, callback: (hasImage: bool) => void)

    2、通过uri移除图片

    //移除图片,一个参数,图片的uri
    static removeImageForTag(uri: string)

    3、存储图片的base64获取uri

    //存储图片的base64编码,三个参数,第一个为图片的二进制编码、第二个为成功的回调、第三个为失败的回调。除非特殊需要,不推荐使用这种方式存储图片。很耗性能。
    static addImageFromBase64( base64ImageData: string, success: (uri: string) => void, failure: (error: any) => void )

    4、通过uri获取图片的base64

    //通过图片的uri获取图片的base64编码,也是三个参数,第一个为图片的uri,第二个和第三个分别是成功和失败的回调,除非特殊需要,不推荐使用。很耗性能。
    static getBase64ForTag( uri: string, success: (base64ImageData: string) => void, failure: (error: any) => void )
  • 相关阅读:
    每日学习
    每日学习——iframe标签伪造ajax
    每日总结
    LA 3667 Ruler
    hdu 2066 一个人的旅行 (dij+heap)
    LA 3507 Keep the Customer Satisfied (Greedy)
    hdu 2527 Safe Or Unsafe
    LA 4636 Cubist Artwork
    hdu 4514 湫湫系列故事——设计风景线(树DP)
    LA 4328 Priest John's Busiest Day (Greedy)
  • 原文地址:https://www.cnblogs.com/XYQ-208910/p/12133067.html
Copyright © 2011-2022 走看看