我只想将鼠标移动到相对于我的应用程序窗口的特定位置。
我找不到实现这种行为的方法,这可能吗?
我想将类似(*float32)的东西转换为(*int32)
我这样做
var f float32 = 0.0
var p *int32 = (*int32)(&f) // error!
// cannot convert &f (type *float32) to type *int32
Run Code Online (Sandbox Code Playgroud)
我怎么能这样做,就像我在C中所做的那样
float f = 0.0;
int *ip = (*int) &fp;
Run Code Online (Sandbox Code Playgroud) 有没有办法重用窗口对象?这可能是必要的,因为相应的窗口可能是动态生成的。
var electron = require('electron');
var app = electron.app
var BrowserWindow = electron.BrowserWindow
app.on('ready', function(){
var win = new BrowserWindow();
win.loadURL 'file://' + __dirname + '/index.html';
// now i want use the window object in my BroserWindow win
window = win.getWindowObject; // like this
window.document.write(); // i can use window object here
});
Run Code Online (Sandbox Code Playgroud) 我听说,JavaScript中的字符串具有不变性.
那么,我怎样才能编写一个方法来替换字符串中的某些字符?
我想要的是:
String.prototype.replaceChar(char1, char2) {
for (var i = 0; i < this.length; i++) {
if (this[i] == char1) {
this[i] = char2;
}
}
return this;
}
Run Code Online (Sandbox Code Playgroud)
然后,我可以像这样使用它:
'abc'.replaceChar('a','b'); // bbc
Run Code Online (Sandbox Code Playgroud)
我知道它不会起作用,因为字符串的不变性.
但在本机代码中,我可以使用这样的本机替换方法:
'abc'.replace(/a/g,'b');
Run Code Online (Sandbox Code Playgroud)
我真的不知道如何解决这个问题.