2017-04-20
remote 调用主进程的全局变量的时候不能传递自己建的对象, 如果强行传递的话会失去私有变量量的限制,然而所有 prototype 的方法都会丢失。icon 的时候不能用系统推荐的 NativeImage 对象,也不能直接用路径,需要用Path对象建立。256*256 大小, 而且不能硬转换, 简单的方法是用 windows 的画图.const platform = process.platform;
function killTask() {
try {
if (platform === 'win32') {
for (let pid of pids) {
childProcess.exec('taskkill /pid ' + pid + ' /T /F');
}
pids = [];
} else {
for (let pid of pids) {
process.kill(processServices.pid);
}
pids = [];
}
} catch (e) {
showInfo('pid not found');
}
clearInterval(timerId);
}
declare function require(name: string);
declare var Vue: any;
原来的我实在是太傻吊了
this 的使用方法其实是 Function 对象在创建的时候自动调用了 Function.call(<this position>),其实在写 function X 的时候我们自动将 this 指向当前的运行环境,比如说某一个class或者整个全局。在使用箭头函数的时候,this 的位置和当前的运行环境相同,比如。
function a() {
this.d = 1;
function b(){
this.f = 2;
function c(){
this.g = 3;
}
}
}
比如说在当前情况下,函数 c 的 this 状况就是 b 的位置。也就是说其实这段代码可以改写成:
function a() {
this.d = 1;
function b(){
this.f = 2;
function c(){
b.g = 3;
}
}
}
与这个不同的是如果 c 是一个箭头函数:
function a() {
this.d = 1;
function b(){
this.f = 2;
let c = ()=>{
this.g = 3;
}
}
}
函数 c 的 this 和 b 的 this 指向的位置是一样的,那么其实我们的 this.g = 3; 改变的是函数 a 的 g 键值。