Help us understand the problem. What is going on with this article?

Electron 7.0.1でwebviewが動かない/表示されない

最初に

これに1時間近くはまってました。。辛かった。。今後のためにも残しておきたいと思いとりあえずQiitaに残しておきます。
*Qiita初投稿でおまけにマークダウンスタイルで書くのにも慣れてないのでなんか変なところがあるかもです。ご了承ください。

問題

htmlを以下のように、

  <!DOCTYPE html>
    <html>
        <head>
            <title>Hello World!</title>
        </head>
        <body>
            <webview src="https://google.com/" autosize="on" minwidth="576" minheight="432"></webview>
        </body>
    </html>

tsを以下のように

///<reference path="./typings/index.d.ts"/>

// In the main process.
const { app, BrowserWindow } = require('electron')
const path = require('path');

const url = "" + __dirname + "/main.html"

app.on('window-all-closed', () => {
    app.quit()
})

app.on('ready', () => {
    let win = new BrowserWindow({ width: 800, height: 600 })
    // load a page
    win.loadURL(url)
    console.log(app.getAppPath())
})

書いたところ何にもレンダリングされない。

解決法

参照: https://github.com/electron/electron/blob/master/docs/api/breaking-changes.md#new-browserwindow-webpreferences-
BrowserWindow内にwebview有効化ということを明記する

  let win = new BrowserWindow({
    width: 1000,
    height: 800,
    'webPreferences': {
        'webviewTag': true
    }

みたいな感じにしてあげたらok

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした