const { app, BrowserWindow, WebContentsView } = require('electron')
app.whenReady().then(() => {
const win = new BrowserWindow({
width: 800,
height: 700,
webPreferences: {
}
})
const view1 = new WebContentsView({
// webPreferences: {
// partition: 'persist:account1'
// }
})
win.contentView.addChildView(view1)
view1.webContents.userAgent
view1.webContents.loadURL('https://m.taobao.com')
view1.setBounds({ x: 0, y: 0, width: 1200, height: 400 })
const view2 = new WebContentsView({
// webPreferences: {
// partition: 'persist:account2'
// }
})
win.contentView.addChildView(view2)
view2.webContents.loadURL('https://m.taobao.com')
view2.setBounds({ x: 0, y: 400, width: 1200, height: 400 })
console.log(win.contentView.children)
})
electron在一个BrowserWindow下创建多个WebContentsView
最新推荐文章于 2024-10-12 19:14:50 发布