私は、サーバーからHTMLコンテンツをダウンロードしてWindowsストレージフォルダ(Windows.Storage.ApplicationData.Current.LocalFolder.Path)に保存しています。 window.location.href = "ms-appdata:///local/inde.html"を使用してそのページに移動すると何も起こりません。 webView.navigate( "ms-appdata:///local/index.html")を使用してナビゲートすると、ページが表示されますが、JavaScriptは実行されません。何でも助けになるだろう。ユニバーサルWindowsアプリケーション(UWP)WebviewでローカルHTMLファイルをロードしていません
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function (id) {
var plugin = new RuntimeComponent.Class;
plugin.InitializeApp().then(function (response) {
try{
(new Windows.UI.Popups.MessageDialog(response, "Title")).showAsync()
}catch(e){
}
});
}
};
app.initialize();
<html>
<head>
<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 *">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" type="text/css" href="css/index.css">
<title>Hello World</title>
</head>
<body>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
</html>
のようなものを使用してナビゲートする必要があると述べた@のようなフォルダ。 'ms-appdata:/// local/folder/file.html'のようなものです。 – tao
@タオ:はい、私はすでにフォルダ内に自分のhtmlを持っています。ちょうど参照のために私は直接ファイルとして言及した。 –