更新 TVOS 模板中的 "Hero Image"
Updating the "Hero Image" in a TVOS template
我正在尝试在 TVOS 中动态更新英雄图像源 productTemplate
。
我可以为描述做到这一点,例如:
function changeDescription(incomingString) {
if (incomingString) {
var theDescription = myDoc.getElementsByTagName("description").item(0);
theDescription.innerHTML = incomingString;
}
}
.. 但它不适用于主图的 src 值:
function changeHeroImage(incomingString) {
console.log("local path: " + incomingString)
if (incomingString) {
var theHero = myDoc.getElementsByTagName("heroImg").item(0);
var theHeroSrc = theHero.getAttribute("src");
theHeroSrc.value = incomingString;
// theHeroSrc.innerHTML = incomingString;
}
}
我已经验证路径是正确的;我还应该看什么?
更新图像应该使用 src
属性,而不是 value
:
function changeHeroImage(incomingString) {
console.log("local path: " + incomingString)
if (incomingString) {
var theHero = myDoc.getElementsByTagName("heroImg").item(0);
theHero.src = incomingString;
}
}
theHero.setAttribute('src', incomingString)
我正在尝试在 TVOS 中动态更新英雄图像源 productTemplate
。
我可以为描述做到这一点,例如:
function changeDescription(incomingString) {
if (incomingString) {
var theDescription = myDoc.getElementsByTagName("description").item(0);
theDescription.innerHTML = incomingString;
}
}
.. 但它不适用于主图的 src 值:
function changeHeroImage(incomingString) {
console.log("local path: " + incomingString)
if (incomingString) {
var theHero = myDoc.getElementsByTagName("heroImg").item(0);
var theHeroSrc = theHero.getAttribute("src");
theHeroSrc.value = incomingString;
// theHeroSrc.innerHTML = incomingString;
}
}
我已经验证路径是正确的;我还应该看什么?
更新图像应该使用 src
属性,而不是 value
:
function changeHeroImage(incomingString) {
console.log("local path: " + incomingString)
if (incomingString) {
var theHero = myDoc.getElementsByTagName("heroImg").item(0);
theHero.src = incomingString;
}
}
theHero.setAttribute('src', incomingString)