❤️写在开头:
本文主要介绍 心知天气API 的应用实例。
🧡开始前的准备:
💛代码实例:#显示区(将该代码放在需要显示天气的地方:
#js区(将该代码放在head.php或者foot.php内均可):
(function(a,h,g,f,e,d,c,b){b=function(){d=h.createElement(g);c=h.getElementsByTagName(g)[0];d.src=e;d.charset="utf-8";d.async=1;c.parentNode.insertBefore(d,c)};a["SeniverseWeatherWidgetObject"]=f;a[f]||(a[f]=function(){(a[f].q=a[f].q||[]).push(arguments)});a[f].l=+new Date();if(a.attachEvent){a.attachEvent("onload",b)}else{a.addEventListener("load",b,false)}}(window,document,"script","SeniverseWeatherWidget","//cdn.sencdn.com/widget2/static/js/bundle.js?t="+parseInt((new Date().getTime() / 100000000).toString(),10)));
window.SeniverseWeatherWidget('show', {
flavor: "slim",
location: "WXMSKZT4B3TT",
geolocation: false,
language: "zh-Hans",
unit: "c",
theme: "auto",
token: "你的Token",
hover: "disabled",
container: "tp-weather-widget"
})
💚效果演示:
如果未显示内容,请刷新