<input type="button" class="btn">
<script>
function fn(data){
console.log(data)
}
let btn = document.querySelector('.btn');
btn.onclick = function(){
// https://www.tianqiapi.com/api/?version=v6&cityid=101110101&appid=68261499&appsecret=IfTIll7V
let sc = document.createElement('script');
sc.src=`https://www.tianqiapi.com/api/?version=v6&city=大同&appid=68261499&appsecret=IfTIll7V&callback=fn`;
document.querySelector('head').appendChild(sc);
}
</script>
天气接口地址:https://www.tianqiapi.com/?action=v1
获取回来的数据