html 中的输入意外结束?

unexpected end of input in html?

我的代码一直给我这个错误“Uncaught SyntaxError: Uncaught SyntaxError: Unexpected end of input”当我点击编辑时,错误在 </script> 中,我不明白为什么,我所有的标签都是关闭

<body>
    
    <header>
        ...
    </header>
    <label id="carrello">Il tuo carrello</label>
    <table id="stampa_piatti">
       ....
    </table>
    <div id="bottone_carrello">
        ....
    </div>
    <script>
        if (sessionStorage.getItem("carrello") === null) {
            document.getElementById("stampa_piatti").innerHTML = "<label><div class = 'carrello_vuoto'>Il tuo carrello è vuoto, " + "<a href = 'C:/Users/Admin/Desktop/FastFood/menu_lista.html'>riempilo</a>!</div></label>";
        } else {
            document.getElementById("bottone_carrello").innerHTML = "<div class = 'bottoni_carrello'><button class='button' onclick='acquisto()'>Procedi all'acquisto</button >" +
                "<button class='button' onclick='location.href='file:///C:/Users/Admin/Desktop/FastFood/menu.html';'>Edit carrello</button></div>";
        }
        var t = mostraCarrello();
    </script>
</body>

onclick='location.href='file:///C:/Users/Admin/Desktop/FastFood/menu.html';'

您需要在引用中使用不同的引用类型:

onclick='location.href="file:///C:/Users/Admin/Desktop/FastFood/menu.html";'

并且因为它已经在另一个引用中,所以可能会转义它:

onclick='location.href=\"file:///C:/Users/Admin/Desktop/FastFood/menu.html\";'

甚至更好:

document.getElementById("bottone_carrello").innerHTML = `
    <div class = 'bottoni_carrello'>
        <button class='button' onclick='acquisto()'>Procedi all'acquisto</button>
        <button class='button' onclick='location.href="file:///C:/Users/Admin/Desktop/FastFood/menu.html";'>Edit carrello</button>
    </div>
`;