本篇基于winform
1.新建winform项目,更改默认Form1窗体为MainForm
2.安装CefSharp.WinForms
Install-Package CefSharp.WinForms -Version 98.1.210
3.MainForm.cs中引用命名空间
using CefSharp;
using CefSharp.WinForms;
4.贴代码,看注释
namespace MyCalc
{
public partial class MainForm : Form
{
public ChromiumWebBrowser chromeBrowser;//浏览器对象
public MainForm()
{
InitializeComponent();
InitializeChromium();//初始化浏览器
//注册js调用类
chromeBrowser.JavascriptObjectRepository.Register("toolBarJs",new ToolBarJs