Javascript 动态添加<;网络视图>;不';行不通

Javascript 动态添加<;网络视图>;不';行不通,javascript,webview,handlebars.js,electron,Javascript,Webview,Handlebars.js,Electron,在我的Electron应用程序中,我希望通过HTML文件动态添加,以便在不同于主渲染器的过程中渲染它们 我使用手柄管理Javascript中的模板 当我动态添加时,它不起作用 在我的渲染器中,我执行以下操作: // library inclusion let templateElement = document.createElement('template') templateElement.innerHTML = Handlebars.compile(document.querySelec

在我的Electron应用程序中,我希望通过HTML文件动态添加
,以便在不同于主渲染器的过程中渲染它们

我使用手柄管理Javascript中的模板

当我动态添加
时,它不起作用

在我的渲染器中,我执行以下操作:

// library inclusion

let templateElement = document.createElement('template')
templateElement.innerHTML = Handlebars.compile(document.querySelector('template').innerHTML)(data) // data contain the id (myWebview) and html (file://[...])
let content = templateElement.content
document.querySelector('#myDiv').appendChild(content.querySelector('#myWebview')) // here, the <webview> is created and placed in the right position

let webview = document.querySelector('webview') // return the <webview>
webview.addEventListener('dom-ready', () => {
    // this event never called
    webview.loadURL(webview.getAttribute('src'))
})
编辑

当我将
直接添加到HTML时,它工作正常。当我通过
更改
时,它会起作用。

我认为
标签会阻止电子公司考虑

为了解决这个问题,我将
标记直接放在HTML中,并使用JavaScript检索它(不使用手柄)

<div id="myDiv"></div>

<script id="template" type="text/x-handlebars-template">
    <webview id="{{id}}" src="{{html}}"></webview>
</script>