Angular: 类型“"periodic-background-sync"”不可分配给类型 'PermissionName'
Angular: Type '"periodic-background-sync"' is not assignable to type 'PermissionName'
我尝试激活后台同步,但在输入代码时出现 运行 错误。
为什么找不到?
我应该更新一些东西吗?
我的代码:
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.
}
}
我看到输入不允许值 '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 我敢说这种周期性同步是一项尚未成熟的现代功能。毫不奇怪打字是不知道的。
我尝试激活后台同步,但在输入代码时出现 运行 错误。 为什么找不到?
我应该更新一些东西吗?
我的代码:
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.
}
}
我看到输入不允许值 '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 我敢说这种周期性同步是一项尚未成熟的现代功能。毫不奇怪打字是不知道的。