小编mar*_*eto的帖子

TypeScript类型忽略大小写

我在TypeScript中有这个类型定义:

export type xhrTypes = "GET" | "POST" | "PUT" | "DELETE" | "OPTIONS" | "CONNECT" | "HEAD";
Run Code Online (Sandbox Code Playgroud)

遗憾的是,这是区分大小写的...有没有办法定义它不区分大小写?

谢谢

types case-insensitive typescript typescript-typings

8
推荐指数
2
解决办法
2959
查看次数

PWA服务人员通知请点击

我正在尝试显示通知,并在单击时做一些事情。

    try {
    navigator.serviceWorker.getRegistration()
        .then(reg => {
            reg.showNotification("Guarda il videoclip!", {
                body: "clicca qua!",
                icon: "images/she_is_fire.png",
                vibrate: [100, 50, 100],
                tag: 'sample',
                actions: [{ action: 'explore', title: 'Guarda', icon: 'images/she_is_fire.png' }],
            });
            self.addEventListener('notificationclick', function(event) {
                event.notification.close();
                window.open("https://youtu.be/PAvHeRGZ_lA");
            }, false);
        })
        .catch(err => alert('Service Worker registration error: ' + err));

} catch (err) {
    alert('Notification API error: ' + err);
}
Run Code Online (Sandbox Code Playgroud)

我添加了事件监听器,但从未触发。

我究竟做错了什么?

javascript notifications progressive-web-apps

4
推荐指数
1
解决办法
3832
查看次数

C#linq排序并取

我正在用C#linq查询。

选择并保存查询后,我必须对它进行排序并接受15行...

var query = from a 
[...]
select new
{
    a.id,
    a.desc,
}
[...]
Run Code Online (Sandbox Code Playgroud)

这样做之间有什么区别吗?

return query.OrderByDescending(o => o.id).Take(15);
Run Code Online (Sandbox Code Playgroud)

和这个?

return query.Take(15).OrderByDescending(o => o.id);
Run Code Online (Sandbox Code Playgroud)

非常感谢你!

c# linq sql-order-by

3
推荐指数
1
解决办法
4376
查看次数