我正试图在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;
}
}
我已经证实路径是正确的;我还应该看看还有什么?
答案 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)
theHero.setAttribute('src', incomingString)