vs2017jscordova+dotnetcore開發app

傑克.陳發表於2018-05-07
原文:vs2017 js cordova + dotnet core 開發app

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


相關文章