我正在尝试禁用 WebView2 运行时的网络安全性,但无法重载 EnsureCoreWebView2Async() 函数。
有什么方法可以将“--disable-web-security”添加到 WinUI3 下的 webview2 运行时?
{
CoreWebView2EnvironmentOptions environmentOptions = new CoreWebView2EnvironmentOptions() {
AdditionalBrowserArguments = "--disable-web-security"
};
CoreWebView2Environment environment = await CoreWebView2Environment.CreateWithOptionsAsync("","", environmentOptions);
await MyWebView.EnsureCoreWebView2Async(environment); #This shows error
MyWebView.Source = new Uri(Path.Combine(Environment.CurrentDirectory, @"Html\mockup.html"));
MyWebView.CoreWebView2.PermissionRequested += CoreWebView2_PermissionRequested;
}
截屏: