每次用户启动应用程序时,应用程序都会要求用户选择“第一”或“第二”。如果用户的选择是“第一”,则显示消息“TEST 1”,或者如果用户的选择是“第二”,则消息是“TEST 2”。
无论我选择什么消息总是“TEST 1”。
我的代码有什么问题?
我怎样才能让它工作?
var msg = new Windows.UI.Popups.MessageDialog("Choose first or second.", "Test");
// Add commands and set their command handlers
msg.commands.append(new Windows.UI.Popups.UICommand("First", commandInvokedHandler));
msg.commands.append(new Windows.UI.Popups.UICommand("Second", commandInvokedHandler));
// Set the command that will be invoked by default
msg.defaultCommandIndex = 1;
// Set the command to be invoked when escape is pressed
msg.cancelCommandIndex = 1;
// Show the message dialog
msg.showAsync();
if (msg = 1) {
// First Choice
var button = document.getElementById("button");
applyButton.addEventListener("click", buttonFirst, false);
} else {
// Second Choice
var button = document.getElementById("button");
applyButton.addEventListener("click", buttonSecond, false);
}
function buttonFirst(eventInfo) {
var greetingString = "TEST 1";
document.getElementById("first").innerText = greetingString;
}
function buttonSecond(eventInfo) {
var greetingString = "TEST 2";
document.getElementById("second").innerText = greetingString;
}