如果在WinJS中选择了一个值或另一个值(1或0,TRUE或FALSE),则需要使用ToggleSwitch:
代码HTML:
<div id="toggleSwitchDocFormat" class="toggleSwitchDocFormat" data-win-control="WinJS.UI.ToggleSwitch" data-win-options="{labelOn:'Guardar Documento Como: TIFF', labelOff:'Guardar Documento Como: PDF', checked:true}"></div>代码Javascript:
app.onloaded = function () {
getDomElements();
toggleSwitchDocFormat = document.getElementById("toggleSwitchDocFormat").winControl;
console.log("the value of the ToggleSwitch: " + toggleSwitchDocFormat.checked);
}消息:
El código de JavaScript estáa punto de biblioteca la excepción en línea 119,第9栏en ms-appx://./js/default.js 0x800a138f - Error en tiempo de ejecución de JavaScript: No se puede la propiedad 'toString‘de sin o sin definir 我的名字是:“我不想控制你,我会继续你的计划”。
当我将ToggleSwitch代码悬停在“未定义”值时,我做错了什么?
如果没有console.log行,ToggleSwitch将在屏幕上正确显示,但我也希望获得它的价值,任何我会感激的帮助
发布于 2014-09-22 19:29:41
试试下面的代码:
args.setPromise(WinJS.UI.processAll().then(function () {
document.getElementById("toggleSwitchDocFormat").winControl.addEventListener("change", function switchChanged(e) {
var _toggleSwitchDocFormat = e.target.winControl;
console.log("is it active??: " + _toggleSwitchDocFormat.checked);
});
}));https://stackoverflow.com/questions/25980586
复制相似问题