运行效果
代码如下
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;namespace WindowsFormsApp1
{public partial class Form1 : Form{public Form1(){InitializeComponent();}private void Form1_Load(object sender, EventArgs e){// webView21.Source =;webView21.Source = new System.Uri($"https://www.microsoft.com/zh-cn/", System.UriKind.Absolute);Debug.WriteLine(webView21.Source);}private void button1_Click(object sender, EventArgs e){string str = $"https://www.douyin.com/?recommend=1";webView21.Source = new System.Uri(str, System.UriKind.Absolute);}}
}
安装包
参考链接
WinForms 应用中的 WebView2 入门 - Microsoft Edge Developer documentation | Microsoft Learnhttps://learn.microsoft.com/zh-cn/microsoft-edge/webview2/get-started/winforms
特此记录
anlog
2025年8月17日