问题
I have tried below code to get indexedDb quota storage information
navigator.webkitTemporaryStorage.queryUsageAndQuota (
function(usedBytes, grantedBytes) {
console.log('we are using ', usedBytes, ' of ', grantedBytes, 'bytes');
},
function(e) { console.log('Error', e); }
);
It is not working and giving the following error.
Property 'webkitTemporaryStorage' does not exist on type 'Navigator'.
Can anyone provide solution for getting indexedDb quota storage information in typescript?
回答1:
The problem lays in missing TypeScript typing. You can consider this answer.
To solve the issue, one solution is to declare the variable of type any
:
let nav: any = navigator;
nav.webkitTemporaryStorage.queryUsageAndQuota (
function(usedBytes, grantedBytes) {
console.log('we are using ', usedBytes, ' of ', grantedBytes, 'bytes');
},
function(e) { console.log('Error', e); }
);
Another way is to extend the interface of Navigator
interface Navigator {
webkitTemporaryStorage: {
queryUsageAndQuota ;
}
}
来源:https://stackoverflow.com/questions/47528131/get-indexeddb-quota-storage-information