1.記得在index.html加入 javascript
<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 *;"> html
<script type="text/javascript" src="scripts/jquery-2.1.4.min.js"></script>java
2.控件click事件綁定jquery
document.querySelector('#button1').addEventListener('click', function () {
$.get("http://192.168.1.102:5000/api/values", function (result) {
alert(result);
});ios
});web
3.dotnet core項目中program.cs設置開啓運行外部訪問api
添加.UseUrls("http://*:5000")ui
以下url
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseUrls("http://*:5000")
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights()
.Build();xml
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