FAQ
Linux系统终端不打印console.log信息
命令行使用--enable-logging=stderr
参数 , 更多信息参考https://www.chromium.org/for-testers/enable-logging
var crypto = require('crypto')
获取对象错误
Chromium拥有一个名为crypto
的全局对象 , 该对象不能被重写 . 所以不能使用crypto
作为变量名 , 更改为其他 , 例如nodeCrypto
便可以使用 .
在AnugarJS中 , 图片使用被打断 , 同时报出Failed to load resource XXX net::ERR_UNKNOWN_URL_SCHEME
的错误
AngularJS为了防止XSS攻击增加unsafe
前缀 . NW.js中的URLs和Chrome应用使用chrome-extension
作为协议头开始 , 不能识别AnuglarJS . 解决方式为将AnuglarJS协议头添加到NW.js白名单配置中 , 方式如下:
myApp.config(['$compileProvider',
function($compileProvider) {
$compileProvider.imgSrcSanitizationWhitelist(/^\s*((https?|ftp|file|blob|chrome-extension):|data:image\/)/);
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|tel|file|chrome-extension):/);
}]);
AngularJS 2中不能打印异常信息
AngularJS 2中试图创建名为global
的全局对象作为异常处理器 . 然而 , 名为global
全局对象已存在于NW.js环境中 , 故不能正常打印异常信息 . 解决方法是重命名NW.js中的global
全局对象给AngularJS使用 . 方式如下:
<script>
window.nw_global = window.global;
window.global = undefined;
</script>
<!-- Angular 2 Dependencies -->
如何使用ESC键退出全屏模式
用户通常使用ESC键退出全屏模式 . NW.js默认不支持ESC快捷键退出全屏模式 , 但提供进入和退出全屏模式的APIs , 提供更多控制全屏模式的方法 .
开启ESC键退出全屏模式 , 可以参考快捷键:
nw.App.registerGlobalHotKey(new nw.Shortcut({
key: "Escape",
active: function () {
// ESC键处理事件 , 退出全屏模式
nw.Window.get().leaveFullscreen();
}
}));