我想動態加載這個腳本,它包含數據屬性<script class="podigee-podcast-player" src="https://cdn.podigee.com/podcast-player/javascripts/podigee-podcast-player.js" data-configuration="https://pt.podigee.io/embed?context=external"></script>我試過了。但這對我不起作用。這是設置數據配置屬性的正確方法嗎?我在哪里犯錯?var script = document.createElement('script'); script.type = 'text/javascript';script.async = true;script.src = 'https://cdn.podigee.com/podcast-player/javascripts/podigee-podcast-player.js';script.class = 'podigee-podcast-player';script.dataset.configuration = 'https://pt.podigee.io/embed?context=external';var s = document.getElementsByTagName("body")[0].appendChild(script, s);
使用數據屬性動態加載腳本
慕森卡
2023-03-18 17:50:30