Nodejs jQuery needs jsdom

后端 未结 5 1088
执笔经年
执笔经年 2021-01-12 17:13
$.getJSON(\'https://api.twitch.tv/kraken/channels/\' + SLoppierKitty7, function(channel) {

if (channel[\"stream\"] == null) { 
    var live =\"no\"

} else {

              


        
5条回答
  •  被撕碎了的回忆
    2021-01-12 17:58

    nothing worked for me from here,

    my jquery version:3.2.1

    jsdom version: 10.1.0 found a solution finally:

    var myHtmlString = 'akkadsf lakuseh alhf lasudfa ls

    '; function jQuery(doc){ const jsdom = require("jsdom"); const { JSDOM } = jsdom; const { window } = new JSDOM(); const JQ = require("jquery")(window)(`${doc || ''}`); } var $ = jQuery; // my html string: var text = $(myHtmlString).text();

提交回复
热议问题