第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

用文字改變圖像

用文字改變圖像

慕容森 2023-11-02 19:58:06
我正在制作一款游戲,根據(jù)玩家所做的選擇,它將顯示新的文本供選擇。我正在嘗試將圖像與該文本連接起來(lái),以便它們能夠適應(yīng)每個(gè)選擇。現(xiàn)在,我的文字可以正常工作,但我的圖像無(wú)法顯示。我在這里做錯(cuò)了什么?  <script type ="text/javascript">    const textElement = document.getElementById('text')    const optionButtonsElement = document.getElementById('option-      buttons')        let state = {}    function startGame() {        state = {}        showTextNode(1)                         }      function showTextNode(textNodeIndex) {      const textNode = textNodes.find(textNode => textNode.id ===      textNodeIndex)      textElement.innerText = textNode.text      document.getElementById('img').src=textNode.img      while (optionButtonsElement.firstChild) {         optionButtonsElement.removeChild(optionButtonsElement.firstChild)        }        textNode.options.forEach(option => {            if (showOption(option)) {            const button = document.createElement('button')            button.innerText = option.text            button.classList.add('btn')            button.addEventListener('click', () =>             selectOption(option))            optionButtonsElement.appendChild(button)                }            })         }        function showOption(option) {        return option.requiredState == null ||         option.requiredState(state)            }        function selectOption(option) {        const nextTextNodeId = option.nextText        if (nextTextNodeId <= 0) {        return startGame()            }        state = Object.assign(state, option.setState)        showTextNode(nextTextNodeId)            }              const textNodes = [        {        id: 1,        Image:url('invitation.jpg'),        text: "You are cordially invited to celebrate Sir Troy         Bennet's 70th birthday! RSVP to attend the event this         evening at the Cherry Hill mansion.",        options: [        {        text: 'RSVP',        nextText: 2        },        {        text: "I'm going to stay home",        nextText: 24        }         ]          },
查看完整描述

1 回答

?
墨色風(fēng)雨

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超6個(gè)贊

這將需要更多上下文,例如 JSFIDDLE 或 CODEPEN 上的可重現(xiàn)示例...但是根據(jù)我所看到的代碼所說(shuō);

textNode.img

當(dāng)你在尋找時(shí);

textNode.Image

17號(hào)線;

document.getElementById('img').src=textNode.img

所以你必須像上面提到的那樣改變Image:url('invitation.jpg'),為beimg:url('invitation.jpg'),或更新textNode.img為be textNode.Image。


查看完整回答
反對(duì) 回復(fù) 2023-11-02
  • 1 回答
  • 0 關(guān)注
  • 149 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)