I. Cache list images
// Load and execute a function for caching images when circulating data
& Lt; script type = "text/x-dot-template" id = "listT" & gt;
{For (var I = 0; I <it. length; I ++ ){}}
{{};}}
& Lt;/script & gt;
// Executed function
Function fnLoadImage (ele _){
Var imageURL = $ api. attr (ele _, 'data-url ');
If (imageURL ){
Api. imageCache ({
Url: imageURL
}, Function (ret, err ){
If (ret. status ){
Ele _. src = ret. url;
$ Api. removeAttr (ele _, 'data _ url ');
}
});
}
}
II. Read cache and clear functions
// Template file
<Ul class = "aui-list-view">
<Li class = "aui-list-view-cell" tapmode onclick = "fn1_ache ()">
<A class = "aui-arrow-right">
Clear Cache
<Span class = "aui-badge-danger" id = 'cachesize'> </span>
</A>
</Li>
</Ul>
// Obtain the cache method
Function fnGetCacheSize (){
Api. getCacheSize (function (ret ){
Var size = parseInt (ret. size/1024/1024*100)/100 + 'mb ';
Var cacheSize = $ api. byId ('cachesize ');
CacheSize. innerHTML = size;
});
}
// Clear cache method
Function fn1_ache (){
Api. showProgress ({
Title: 'clearing cache ...',
});
Api. Sort ache (function (){
SetTimeout (function (){
Api. hideProgress ();
FnGetCacheSize ();
}, 500)
});
}
III. Monitor real-time changes in cache
// Listen for real-time cache changes in the callback method of frameGroup
If (ret. index = 3 ){
Var jsfun = 'fngetcachesize ();';
Api.exe cScript ({
FrameName: 'frame3 ',
Script: jsfun
});
}