我写了下面的代码[Windows Store JavaScript App
]:获得价值:Windows应用商店的应用程序的JavaScript
function get_ver(){
get_text("verfile");
// how to get value read by get_text [i.e. variable filedata] in this function???
}
function get_text(filepath) {
var p = "ms-appx:///" + filepath;
var uri = new Windows.Foundation.Uri(p);
Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri)
.then(function (sampleFile) {
return Windows.Storage.FileIO.readTextAsync(sampleFile);
}).done(function (filedata) {
document.getElementById("t").innerHTML = filedata;
// want to return filedata to get_ver()
}
);
}
我要访问从“verfile” [即读取数据get_ver()中的变量filedata的值可以作为返回值。如何做?
而不是将值设置为元素的innerHTML我希望它应该返回给调用者,以便它可以进一步处理。
你想要哪个值? –
'filedata'的值,即从文件中读取。 – TheCrazyProgrammer