1.记得在index.html加入
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *;connect-src *;">
<script type="text/javascript" src="scripts/jquery-2.1.4.min.js"></script>
2.控件click事件绑定
document.querySelector('#button1').addEventListener('click', function () {
$.get("http://192.168.1.102:5000/api/values", function (result) {
alert(result);
});
});
3.dotnet core项目中program.cs设置开启运行外部访问
添加.UseUrls("http://*:5000")
如下
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseUrls("http://*:5000")
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights()
.Build();
host.Run();
}
}
4.移动设备webview浏览网页需要在config.xml中添加 <allow-navigation href="*" />
<p>
<a href="http://www.baidu.com">jump web</a>
</p>
http://stackoverflow.com/questions/36036475/cordova-6-0-ios-load-external-url-in-the-webview