我希望这不是太多的代码来查看我认为可能是一些语法错误。我遇到了很多不同类型的错误,并尝试将此代码编译,但最新的是 “在ms-appx://io.cordova.myapp7523d86d4f8a4241bd8c3bad3d5fe0a3/www/scripts/index.js第33行第33行检测到严重错误.SETIPT1006:预期')”,这是“setPlaceholderImage()”行。
这是一个练习模板应用程序,可以在https://msdn.microsoft.com/en-us/magazine/dn879349.aspx找到:TITLED:跨平台:使用Apache Cordova在Visual Studio中编写跨平台混合应用程序。
(function () {
"use strict";
document.addEventListener('deviceready', onDeviceReady.bind(this), false);
function onDeviceReady() {
// Perform other initialization here.
};
locate();
document.getElementById("btnLocate").addEventListener("click", locate);
(function locate() {
navigator.geolocation.getCurrentPosition(function (position) {
App.lastPosition = {
latitude: position.coords.latitude,
longitude: position.coords.longitude,
address: "( position.coords.latitude )" + "( position.coords.longitude )" };
// Go translate the coordinates into an address using the Bing Map Web API.
updatePosition();
}, function (error) {
WinJS.log && WinJS.log("Unable to get location: "
+ error.message, "app");
}, {
maximumAge: 3000, timeout: 10000, enableHighAccuracy: true
});
}
setPlaceholderImage(){
document.getElementById("photo").addEventListener("click", capturePhoto.bind(photo));
}
function capturePhoto() {
var photoDiv = this;
// Capture camera image into a file.
navigator.camera.getPicture(cameraSuccess, cameraError) {
quality: 50,
destinationType: Camera.DestinationType.FILE_URL,
encodingType: Camera.EncodingType.JPEG,
mediaType: Camera.MediaType.PICTURE,
allotEdits: true
correctOrientation: true
});
function cameraSuccess(imageFile) {
// Save for share and enable Share button.
App.lastCapture = imageFile;
document.getElementById("btnShare").disabled = false;
// Do letterboxing and assign to img.src.
scaleImageToFit(photoDiv.querySelector("img"),
photoDiv, App.lastCapture);
};
function cameraError(error) {
WinJS.log && WinJS.log("Unable to obtain picture: " + error, "app");
};
}
document.getElementById("btnShare").addEventListener("click", App.share);
function share() {
var txtLocation = document.getElementById("txtLocation").value;
plugins.socialsharing.share("At " + txtLocation, "Here My Am!",
App.lastCapture);
}
} )();