首页 > 解决方案 > “webview”不是电子角度应用程序中的已知元素

问题描述

我正在使用电子创建桌面应用程序。我们需要加载网页并与网页交互。

我们开始知道电子有什么标签

根据文档,这是我们的main.js文件配置

mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      nodeIntegration: true,
      webviewTag: true <--------------- as said by the documentation
    }
  })

现在是我们添加了这个标签的webpage.component.html文件

<webview src="https://www.github.com/"></webview>

这是我们的web-page.component.ts文件

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'webpage',
  templateUrl: './webpage.component.html',
  styleUrls: ['./webpage.component.scss']
})
export class WebpageComponent implements OnInit {

  constructor() { }

  ngOnInit(): void {
  }

}

但是我们一次又一次地收到这个错误,我们不知道我们做错了什么!

ERROR in src/app/webpage/webpage.component.html:1:1 - error NG8001: 'webview' is not a known element:
1. If 'webview' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.

1 <webview src="https://www.github.com/"></webview>
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  src/app/webpage/webpage.component.ts:5:16
    5   templateUrl: './webpage.component.html',
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Error occurs in the template of component WebpageComponent.

想知道我们做错了什么!

标签: javascriptangularwebviewelectron

解决方案


推荐阅读