【发布时间】:2019-09-02 01:18:33
【问题描述】:
我一遍又一遍地创建窗口变量,我怎样才能只声明一次? 我尝试将它添加到构造函数中,但没有奏效。
import { Component } from '@angular/core';
import { ElectronService } from 'ngx-electron';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.sass']
})
export class AppComponent {
title = 'ae-test';
constructor(
private _ES: ElectronService,
) {}
minWindow() {
const window = this._ES.remote.getCurrentWindow();
window.minimize();
}
fullscreenWindow() {
const window = this._ES.remote.getCurrentWindow()
if (window.isFullScreen() == true) {
window.setFullScreen(false);
} else {
window.setFullScreen(true);
}
}
closeWindow() {
const window = this._ES.remote.getCurrentWindow();
window.minimize();
}
}
【问题讨论】:
-
只需将其绑定到类属性并在构造函数中初始化即可。
标签: javascript angular typescript electron