有两个我不明白的问题。
第一个是将一个片变量分配给另一个变量,并且发现新变量的地址与该变量的地址不一致。我的理解是slice共享内存,并且根据原理它们的地址是相同的。
然后是秒,当slice变量的容量不足时,追加操作后内存地址不会更改。它应该根据原理进行更改,因为在容量不足时将重新分配内存地址。
感谢您的评论。
0xc04204c3a0
0xc04204c3e0
0xc04204c3e0
[1 2 3]
[1 2 3 0]
运行结果是:
// index.js
function createWindow () {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,height: 600,webPreferences: {
preload: path.join(__dirname,'preload.js'),nodeIntegration : true
}
})
// and load the index.html of the app.
mainWindow.loadURL(`${__dirname}/index.html`)
// This is the actual solution
mainWindow.webContents.on("new-window",function(event,url) {
event.preventDefault();
shell.openExternal(url);
});