我找不到这个错误的解决方案我在网站上使用多种语言工作,但我不知道如何修复这个错误class translate{constructor(){ document.getElementById("fr").addEventListener('click', ()=>{ this.translate("fr"); }); document.getElementById("en").addEventListener('click', ()=>{ this.translate("en"); }); this.translate(localStorage.getItem("language"));}translate(language){ if(language == "fr"){ document.getElementById("myAnchor").href = "http://www.cnn.com/"; } else if (language =="en"){ document.getElementById("myAnchor").href = "http://www.google.com/"; } localStorage.setItem("language",language);}}onload = new translate();我需要更改的代码 Html 和链接 <div class="contenu-space-two"> <div class="row mx-0"> <div class=" col-2"> <img src="./resources/_images/shopping-cart.png" class="logo-link" alt=""> </div> <div class="col-lg-4 col-md-6 col-8" > <h4 class="lang" key="boutiques">Boutiques</h4> </div> <div class="col-2"> <a id="myAnchor" href="#"><img src="./resources/_images/arrow-link.png" class="arrow-link" alt=""></a> </div> <hr class="line_link"> </div>和这种代码语言 <div id="langContainer"> <a class="translate" id="lang_link[en]" href="#" style="display:none"><img src="./resources/_images/flags/en.png?1595436503" title="English"></a> <a class="translate" id="lang_link[fr]" href="#" style="display:none"><img src="./resources/_images/flags/fr.png?1595436503" title="Français"></a> </div>
添加回答
举报
0/150
提交
取消