taro-rn-clear-cache

1.3.0 • Public • Published

用法

import clear from 'taro-rn-clear-cache';

constructor () {
    super();
    this.state = {
      cacheSize:"",
      unit:"",
    }
    clear.getCacheSize((value,unit)=>{
      this.setState({
        cacheSize:value, //缓存大小
        unit:unit  //缓存单位
      })
    });
    
  }
  
  render() {
    return (
      <View style={{flex: 1,justifyContent: 'center',alignItems: 'center'}}>
        <Text style={{fontSize: 20,textAlign: 'center',margin: 10}}>
          缓存大小{this.state.cacheSize}{this.state.unit}
        </Text>
        <Button title="清除缓存" onPress={this.clearCache.bind(this)}/>
      </View>
    );
  }
  
  clearCache(){

    clear.runClearCache(()=>{

      console.log("清除成功");

    clear.getCacheSize((value,unit)=>{
      this.setState({
        cacheSize:value, //缓存大小
        unit:unit  //缓存单位
      })
    });
      
    });

  }

Readme

Keywords

none

Package Sidebar

Install

npm i taro-rn-clear-cache

Weekly Downloads

2

Version

1.3.0

License

ISC

Unpacked Size

29.9 kB

Total Files

18

Last publish

Collaborators

  • fairy_zhao