我在Bluebird/Promises中遇到了一些问题.对于Promise1,如果调用fullfill或reject,一切正常.但是当我们在finally块中返回Promise2时,它只适用于reject和fullfil,我们在后面的回调中得到了未定义.
function getPromise1() {
return new Promise(function(fulfill, reject) {
fulfill("OK1");
});
}
function getPromise2() {
return new Promise(function(fulfill, reject) {
fulfill("OK2");
});
}
getPromise1()
.then(function(c){
console.log(c);
})
.catch(function(e) {
console.log(e);
})
.finally(function() {
return getPromise2();
})
.then(function(c){
console.log(c);
})
.catch(function(e) {
console.log(e);
});
Run Code Online (Sandbox Code Playgroud)
输出:
OK1
未定义
我正在开发相当大的SPA(最终约30MB),不幸的是,其中一个要求是必须将应用程序作为一个大的html文件发布.我使用webpack将所有部分连接在一起.
目前我遇到了性能问题(有些库很大).由于浏览器中的代码评估,它们会"吃掉"大量内存并影响加载时间.我想推迟它并仅评估应用程序主屏幕所需的这些模块.
我的想法是使用像webpack一样的机制来实现源映射:
https://webpack.js.org/configuration/devtool/(eval- source-map)
Webpack只是将代码置于eval("模块代码")中,这阻止了Javascript引擎的自动评估.当然这个代码不能缩小,并且还有一个sourcemap作为base64附加到最后.我想在没有源图和包括uglification的情况下做同样的事情.此外,我有一个想法,通过压缩源来减少应用程序的大小,所以最终它将是eval(gz.decompress("模块代码")).
这将是一个巨大的应用变化,所以在我要重新发明轮子之前,我想问你:
https://webpack.github.io/docs/code-splitting.html
或者从头开始编写自己的解决方案(loader/plugin).
我设置了自己的光标:
HCURSOR hCurStandard = LoadCursorFromFile(TEXT("cursor.cur"));
SetSystemCursor(hCurStandard, 32512);
DestroyCursor(hCurStandard);
Run Code Online (Sandbox Code Playgroud)
如何返回并设置默认光标?
这不起作用:
SetSystemCursor(LoadCursor(0, IDC_ARROW), 32512);
Run Code Online (Sandbox Code Playgroud)
- - 编辑 - - -
HCURSOR hcursor = LoadCursor(0, IDC_ARROW);
HCURSOR hcursor_copy = CopyCursor(hcursor);
BOOL ret = SetSystemCursor(hcursor_copy, OCR_NORMAL);
DestroyCursor(hcursor);
Run Code Online (Sandbox Code Playgroud)
这适用于除IDC_ARROW之外的所有游标,是什么......?