共用方式為


CoreWebView2ExecuteScriptResult Class

The result for CoreWebView2.ExecuteScriptWithResultAsync.

Summary

Members Description
Exception If Succeeded is false, you can use this property to get the unhandled exception thrown by script execution
ResultAsJson A function that has no explicit return value returns undefined. If the script that was run throws an unhandled exception, then the result is also null.
Succeeded This property is true if CoreWebView2.ExecuteScriptWithResultAsync successfully executed script with no unhandled exceptions and the result is available in the CoreWebView2ExecuteScriptResult.ResultAsJson property.
TryGetResultAsString If Succeeded is true and the result of script execution is a string, this method provides the value of the string result, and we will get the false var value when the js result is not string type.

Properties

Exception

readonly CoreWebView2ScriptException Exception

If Succeeded is false, you can use this property to get the unhandled exception thrown by script execution

ResultAsJson

readonly string ResultAsJson

A function that has no explicit return value returns undefined. If the script that was run throws an unhandled exception, then the result is also null.

Succeeded

readonly bool Succeeded

This property is true if CoreWebView2.ExecuteScriptWithResultAsync successfully executed script with no unhandled exceptions and the result is available in the CoreWebView2ExecuteScriptResult.ResultAsJson property.

Methods

TryGetResultAsString

int TryGetResultAsString(out string stringResult)

If Succeeded is true and the result of script execution is a string, this method provides the value of the string result, and we will get the false var value when the js result is not string type.