我试图弄清楚如何使用 TVJS 从 TVML 中的 textField 获取值,但我还没有找到任何关于它的文档,我不想等待文档更新。实际上没有任何绑定到输入的模式,因为我确定这是除了登录服务之外很少使用的用例。我想我可以解析 Xml 但这似乎超级hacky。
我最终自己弄清楚了。我必须使用来自 select 事件对象的回调,然后将文本元素传递给一个函数来处理该事件。
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;
}
Run Code Online (Sandbox Code Playgroud)
一旦我有了节点,我就使用苹果 TVJS 函数 getFeature('Keyboard') 从这个对象中获取文本值。
| 归档时间: |
|
| 查看次数: |
1377 次 |
| 最近记录: |