2017-12-19 22 views
2

전자에서, <webview>을 HTML 파일을 통해 동적으로 추가하여 주 렌더러와 다른 프로세스에서 렌더링합니다.동적으로 추가하는 <webview>이 작동하지 않습니다.

핸들을 사용하여 자바 스크립트에서 내 템플릿을 관리합니다.

<webview>을 동적으로 추가하면 작동하지 않습니다.

내 렌더러에서

, 나는 그렇게 : 여기

// 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에 직접 <webview>을 추가, 제대로 작동

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

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

편집 . 그리고 내가 <webview>을 으로 바꾸면 작동합니다.

답변

0

<script> 태그는 <webview>이 전자로 고려되지 않았다고 생각합니다.

이 문제를 해결하기 위해 <webview> 태그를 HTML에 직접 넣고 JavaScript (Handlebars를 사용하지 않고)로 검색합니다.