Tag: 天气

node.js:雅虎天气的jQuery插件不打印数据

我得到了node.js与jQuery和这个插件: http : //simpleweatherjs.com/ 。 现在我想使用另一个服务的天气数据,而不是把它放到HTML中,但我不能访问/打印数据。 错误function起作用,成功function不起作用。 var jsdom = require("jsdom"); jsdom.env({ html: '<html><body><div id="weather"></div></body></html>', scripts: [ 'http://code.jquery.com/jquery-2.1.1.min.js', 'http://cdnjs.cloudflare.com/ajax/libs/jquery.simpleWeather/3.0.2/jquery.simpleWeather.min.js' ], done: function(errors, window) { var $ = window.jQuery; $.simpleWeather({ location: 'Paris', woeid: '615702', unit: 'c', success: function(weather) { console.log(weather.temp+'°'+weather.units.temp); }, error: function(error) { console.log(error.message); } }); } }); 这是正常的http://codepen.io/fleeting/pen/xwpar 还有一个插件的节点模块,但是我不知道如何使它工作,没有文档。