首先配置权限 在 package.json 中添加以下 partitions 内容

{
  "webview": {
    "partitions": [
       {
         "name": "trusted",
         "accessible_resources": [ "<all_urls>" ]
       }
    ]
  }
}

然后为webview 的dom节点添加属性 partitions="true"

<webview partition="trusted"></webview>

之后就可以使用 src 属性加载本地文件。

或者使用javascript:

    var webview = document.createElement("webview")
    webview.partition="trusted"

    webview.src = "test/index.html"
    document.body.appendChild(webview)

参考https://nwjs.org.cn/doc/api/webview-Tag.html