我试图激活后台同步,但我运行错误时,我键入代码。为什么找不到呢?
我应该更新一些东西吗?
我的代码:
if ('periodicSync' in worker) {
const status = await navigator.permissions.query({
name: 'periodic-background-sync', //ERROR
});
// Periodic background sync can be used.
if (status.state === 'granted') {
const tags = await worker.periodicSync.getTags(); //ERROR
if (!tags.includes('sendDbDatas')) {
worker.periodicSync.register('sendDbDatas'); //ERROR
}
} else {
// Periodic background sync cannot be used.
}
}发布于 2020-06-05 16:28:27
我发现类型不允许值‘periodic background-sync’。
interface DevicePermissionDescriptor extends PermissionDescriptor {
deviceId?: string;
name: "camera" | "microphone" | "speaker";
}作为一种解决办法,您可以使用强制转换到任何。
const status = await navigator.permissions.query({
name: <any>'periodic-background-sync'
});看看Web Periodic Background Synchronization draft,我敢说这种周期性的同步是一个还不成熟的现代特性。毫不奇怪,键入没有意识到这一点。
https://stackoverflow.com/questions/62210777
复制相似问题