在创建新的客户端-服务器 tvOS 应用程序时,tvOS 不会从我的外部tvml
文件中获取数据。这是错误:ITML <Error>: Failed to load launch URL with error: (null)
这是main.js
代码
function getDocument(url) {
var templateXHR = new XMLHttpRequest();
templateXHR.responseType = "document";
templateXHR.addEventListener("load", function() {pushDoc(templateXHR.responseXML);}, false);
templateXHR.open("GET", url, true);
templateXHR.send();
return templateXHR;
}
function pushDoc(document) {
navigationDocument.pushDocument(document);
}
App.onLaunch = function(options) {
var templateURL = 'niclasblog.com/appletv/main.tvml';
getDocument(templateURL);
}
App.onExit = function() {
console.log('App finished');
}
我也附上了main.tvml
文件
<document>
<alertTemplate>
<title>Test</title>
<description>This is a test</description>
<button>
<text>Yes</text>
</button>
<button>
<text>No</text>
</button>
</alertTemplate>
</document>
该代码直接来自 Apple 文档,所以我不知道为什么它不起作用。