更新TVOS模板中的“Hero Image”

时间:2016-02-14 18:29:54

标签: javascript tvos tvml tvjs

我正试图在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;
    }
}

我已经证实路径是正确的;我还应该看看还有什么?

2 个答案:

答案 0 :(得分:0)

更新图片应使用src属性,而不是value

function changeHeroImage(incomingString) {
    console.log("local path: " + incomingString)
    if (incomingString) {
        var theHero = myDoc.getElementsByTagName("heroImg").item(0);
        theHero.src = incomingString;
    }
}

答案 1 :(得分:0)

尝试setAttribute

theHero.setAttribute('src', incomingString)