代码在codepen中运行良好,但当尝试在WordPress页面中使用短代码运行时,它没有运行。可能是什么原因。此代码下面的所有剩余内容也没有显示。特别是当尝试在页面中运行js时,没有显示任何内容。
<script>
// Fetch the exchange rates from the API
fetch(`https://api.fastforex.io/fetch-multi?from=AED&to=USD,EUR,GBP,INR,AUD,CAD,SGD,CHF,MYR,JPY&api_key=xxxxx-xxx-xxx`)// API key on purpose
.then(response => response.json())
.then(data => {
// Update the exchange rates in the table
document.getElementById("eur").innerHTML = data.results.EUR;
document.getElementById("gbp").innerHTML = data.results.GBP;
document.getElementById("chf").innerHTML = data.results.CHF;
document.getElementById("eur").innerHTML = data.results.EUR;
document.getElementById("gbp").innerHTML = data.results.GBP;
document.getElementById("chf").innerHTML = data.results.CHF;
document.getElementById("usd").innerHTML = data.results.USD;
document.getElementById("inr").innerHTML = data.results.INR;
document.getElementById("aud").innerHTML = data.results.AUD;
document.getElementById("cad").innerHTML = data.results.CAD;
document.getElementById("sgd").innerHTML = data.results.SGD;
document.getElementById("myr").innerHTML = data.results.MYR;
document.getElementById("jpy").innerHTML = data.results.JPY;
});
</script>
</body>
1条答案
按热度按时间zbsbpyhn1#
你在使用它之前排队了吗?