我正在尝试弄清楚如何使用 TVJS 从 TVML 中的文本字段获取值,但我还没有找到任何相关文档,而且我不想等待文档更新。实际上没有任何绑定到输入的模式,因为我确信除了登录服务之外这是很少使用的情况。我想我可以解析 Xml,但这看起来非常老套。
我最终自己弄清楚了。我必须使用选择事件对象的回调,然后将文本元素传递到函数中来处理该事件。
function template() {
var template = "<document><formTemplate><textField id="email">Your email</textField><footer><button><text>Submit</text></button></footer></formTemplate></document>";
var parser = new DOMParser();
var doc = parser.parseFromString(template , "application/xml");
var email = doc.getElementById("email");
doc.addEventListener("select", function() { submit(email); });
}
function submit(textField) {
var keyboard textField.getFeature('Keyboard');
var email = keyboard.text;
}
获得节点后,我使用 Apple TVJS 函数 getFeature('Keyboard') 从此对象获取文本值。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)