【发布时间】:2016-07-04 15:31:01
【问题描述】:
我将简单的 html 文件(保存在项目中)加载到 WebView。它加载成功并显示“Hello World”标题。
文件 index.html
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>ABC</title>
<script>
function SayHello() {
return "hello";
};
</script>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
加载到 WebView
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
webView.Navigate(new Uri("ms-appx-web:///index.html", UriKind.RelativeOrAbsolute));
// Exception below line
var data = await webView.InvokeScriptAsync("eval", new List<string> { "SayHello();" });
Debug.WriteLine(data);
}
我不明白为什么会这样。它在谷歌浏览器上成功运行。我错过了什么吗?
【问题讨论】:
-
异常详情是什么?
-
只是 System.Exception
标签: windows-phone win-universal-app